• Post Reply Bookmark Topic Watch Topic
  • New Topic

NonGeneric Usage  RSS feed

 
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why i am getting output for s2 as "with generics" instead of object. What i assume is that return type of get is Object without generics and so we have assigned Object s2=stringList1.get(1) but why i am getting "with generics" whereas i have to get an object as value in System.out.println(s2);
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Object that you are getting out of the list is in fact a String. A String is also an Object!

If this is not what you expected, then what did you expect?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!