• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem getting ArrayList from servlet context attribute  RSS feed

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting this compile warning...
warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
...when from line 2 of this code...


I've tried...

...and various other, messier, alternatives but can not get a clean solution.

Can anyone help?

Thanks,
James
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried this?.

 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because neither the compiler nor the JVM can guarantee that the object is an ArrayList<HttpSession>, only that it's an ArrayList, you will never get this to work without a warning. So in cases like this you have to suck it up and use @SuppressWarnings("unchecked").
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, thanks to you both.
 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!