O'Reilly logo
  • Sankara Vadivel Dhandapani thinks this is interesting:

The compiler may not be able to prove that your program is typesafe, but you can. You must convince yourself that the unchecked cast will not compromise the type safety of the program. The array in question (elements) is stored in a private field and never returned to the client or passed to any other method. The only elements stored in the array are those passed to the push method, which are of type E, so the unchecked cast can do no harm.


Cover of Effective Java, 2nd Edition


Nice example how you can prove the warning generated for type safety by compiler can be proved to be not an issue