It's not a secret anymore!*
The moose likes Beginning Java and the fly likes java.lang.ClassCastException: java.util.ArrayList incompatible with java.lang.String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java.lang.ClassCastException: java.util.ArrayList incompatible with java.lang.String" Watch "java.lang.ClassCastException: java.util.ArrayList incompatible with java.lang.String" New topic
Author

java.lang.ClassCastException: java.util.ArrayList incompatible with java.lang.String

Aditya Sirohi
Ranch Hand

Joined: Jan 05, 2010
Posts: 93

Hello Folks,

I am seeing an error in the following snippet of code. what am i doing wrong here?




Thanks
Aditya
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4425
    
    8

Have a closer look at the operations where you're adding data to main. Are you sure they're all adding Strings?
Aditya Sirohi
Ranch Hand

Joined: Jan 05, 2010
Posts: 93

Thanks Matthew,


Yes you were correct, i added some generics to the collections and it worked. Thanks for helping me out.

-Aditya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.ClassCastException: java.util.ArrayList incompatible with java.lang.String