Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • If you're using HttpSession like that, check out Brian Goetz's article on the subject: ibm.com/developerworks/library/j-jtp09238.html Commented Feb 4, 2009 at 15:33
  • If an unchecked cast is unavoidable, a good idea is to tightly couple it with something that logically represents it's type (like an enum or even instances of Class<T>), so you can glance at it and know it's safe. Commented Jul 17, 2012 at 2:39
  • 4
    Related/dupe: Type safety: Unchecked cast Commented Mar 11, 2013 at 19:15
  • 3
    possible duplicate of Type safety: Unchecked cast Commented May 17, 2013 at 12:54
  • 1
    I would add, I found I could only add @SuppressWarnings("unchecked") at the method level that contains the offending code. So I broke the code out to a routine where I had to do this. I always thought you could do this immediately above the line in question. Commented Jan 15, 2020 at 17:23