473,395 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

class cast Exception

what is class cast exception? why it comes.
I am getting this exception when i am running my application.
class files are getting compiled sucessfully.
Please help.
Jan 18 '08 #1
3 1874
r035198x
13,262 8TB
what is class cast exception? why it comes.
I am getting this exception when i am running my application.
class files are getting compiled sucessfully.
Please help.
Always refuse to write a single line of code if you don't have the Java docs with you.
Jan 18 '08 #2
dmjpro
2,476 2GB
what is class cast exception? why it comes.
I am getting this exception when i am running my application.
class files are getting compiled sucessfully.
Please help.
Paste your code here.
I am showing you a example.
Expand|Select|Wrap|Line Numbers
  1. Vector v = new Vector();
  2. v.add(new YourClass1());
  3. YourClass2 obj = v.elementAt(0);
  4.  
Now what you would happen?
Here YourClass1 and YourClass2 are two different classes.

Debasis Jana.
Jan 18 '08 #3
BigDaddyLH
1,216 Expert 1GB
Paste your code here.
I am showing you a example.
Expand|Select|Wrap|Line Numbers
  1. Vector v = new Vector();
  2. v.add(new YourClass1());
  3. YourClass2 obj = v.elementAt(0);
  4.  
Now what you would happen?
Here YourClass1 and YourClass2 are two different classes.

Debasis Jana.
This code doesn't compile. I think you meant for it to compile, but to have a runtime exception. So make the last line of code:

Expand|Select|Wrap|Line Numbers
  1. YourClass2 obj = (YourClass2) v.get(0);
Jan 18 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

822
by: Turamnvia Suouriviaskimatta | last post by:
I 'm following various posting in "comp.lang.ada, comp.lang.c++ , comp.realtime, comp.software-eng" groups regarding selection of a programming language of C, C++ or Ada for safety critical...
17
by: ahaupt | last post by:
Hi all, I'm currently writing a load of class libraries, but not the main application iteslf. I want to provide some method for reporting errors back to the main application. At the moment...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
9
by: Brian Henry | last post by:
If i inherite a queue class into my class, and do an override of the enqueue member, how would i then go about actually doing an enqueue of an item? I am a little confused on this one... does over...
10
by: Chet Cromer | last post by:
I am creating a set of base classes and sub classes to use throughout a program I'm developing. The base class represents a generic "lookup table" from my database that contains lists of things...
1
by: olrt | last post by:
Hello, I have designed a WebService with the following method : public DbAppAnswer GetDs(DbAppRequest request) DbAppRequest and DbAppAnswer are defined as :
14
by: budy_ludy | last post by:
Hi All, I am new to vb .net, I have an ArrayList and i store class objects in it, and later i want to retrieve each ArrayList items and type cast to the class, How can it be done ? I used...
6
by: Ron M. Newman | last post by:
Hi, Under what circumstances can I ever get an exception about not being able to cast type "ABC" to type "ABC" if there's only one ABC class in the system and it's loaded from a dynamic...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
12
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
Hi, I have a class which "BiologySequence" which looks about like this. public class BiologySequence { private string _Sequence; public string Sequence {
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.