🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #671

ArrayList.toArray() gives class cast exception

#671
From: Ayhan Molla
Date: Wed, 16 Apr 2003 06:59
10 lines
1174 bytes
Hi all,
The following fragment gives ClassCastException without any reason that I
can explain.
<I got Item class extends Object>
ArrayList aList = new ArrayList() ;
for(int i=0; i < 10;++i)
    aList.add( new Item() ) ;

Item [] list = (Item []) aList.toArray() ; <-- this line give class cast
exception
Technical Details
Message-ID: <3e9cff00@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,5c0e8f08630b5fc1,start
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2003-04-16 00:03:39 PST
From: "Ayhan Molla" <amolla@havelsan.com.tr>
Newsgroups: borland.public.jbuilder.java.api
Subject: ArrayList.toArray() gives class cast exception
Date: Wed, 16 Apr 2003 09:59:41 +0300
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 195.142.153.2
Message-ID: <3e9cff00@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1050476288 195.142.153.2 (15 Apr 2003 23:58:08 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!newsgroups.borland.com!not-for-mail