• Post Reply Bookmark Topic Watch Topic
  • New Topic

wildcard unknown type element  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

line 6 can produce output
but in line 9 caused compile error incovertible type
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This line:


says "cast nl2 to a number", not "cast the elements of nl2 to numbers." You can't cast a List to a number. And you don't need the cast here because nl2 is already ArrayList<Number>, so just



is fine.

And in this particular case, since you're just calling println(n) you could have just treated them as Object anyway. (I know that's just a placeholder--just teasing you a little )
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!