• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Aditya Sirohi
Ranch Hand
Posts: 93
Eclipse IDE Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Folks,

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




Thanks
Aditya
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 93
Eclipse IDE Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Matthew,


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

-Aditya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic