This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Arrays.asLIit() casting exception (JDK 1.4) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Arrays.asLIit() casting exception (JDK 1.4)" Watch "Arrays.asLIit() casting exception (JDK 1.4)" New topic
Author

Arrays.asLIit() casting exception (JDK 1.4)

FY Hsieh
Ranch Hand

Joined: Aug 07, 2006
Posts: 73
I have



First I want to mention this is not jdk 1.5 or beyond, it is 1.4.
The compilation is OK but gives run time exception of Class Cast for "Arrays.asList()" part. what's wrong and how should I fix it ?

Thanks.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It returns a List, not an ArrayList, no?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63195
    
  69

asLIit()?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Yeah, it's like asList, but more learned, and in Olde English.

http://shakespearelang.sourceforge.net/report/shakespeare/
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 595
    
    7

David,

i saw your reply and laughed good 10 minutes. :-) Thank you
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20077
    
  30

David Newton wrote:It returns a List, not an ArrayList, no?

Actually it does return an ArrayList, just not java.util.ArrayList. The returned class is java.util.Arrays.ArrayList, a private static class inside class java.util.Arrays. But yeah, you're right that as far as the API is concerned, it does return a List.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arrays.asLIit() casting exception (JDK 1.4)
 
jQuery in Action, 3rd edition