Class cast exception
From: Will (larkmore_at_aol.com)
Date: 10/18/04
- Next message: Jay Sartoris: "Adding comment above root Node using DOM"
- Previous message: Scott Ellsworth: "Re: How can we beat team system?"
- Next in thread: Joona I Palaste: "Re: Class cast exception"
- Reply: Joona I Palaste: "Re: Class cast exception"
- Reply: slrncalmac.2.chess_at_spamgourmet.com: "Re: Class cast exception"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 18 Oct 2004 11:51:51 -0700
I get a Class Cast Exception at runtime with the following code, and
was wondering why this isn't allowed:
Vector v = new Vector();
//do some stuff to fill in v with a bunch of Strings
String [] s = (String [])(v.toArray());
The toArray method returns an Object [] so why can't I cast it to a
String [] if I know that everything in it will be a String? The only
workaround I've found is to make a second array and manually copy and
cast each element of the first array into the second array.
-Will
- Next message: Jay Sartoris: "Adding comment above root Node using DOM"
- Previous message: Scott Ellsworth: "Re: How can we beat team system?"
- Next in thread: Joona I Palaste: "Re: Class cast exception"
- Reply: Joona I Palaste: "Re: Class cast exception"
- Reply: slrncalmac.2.chess_at_spamgourmet.com: "Re: Class cast exception"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|