0

Consider the following clause of JLS8:ยง5.5.2

A cast from a type S to a type variable T is unchecked unless S <: T.

Here is how I tried to implement the understanding around the scenario that JLS tries to discuss:

class Scratch {
  public static <T extends Number> void  hitMe(T a){
    T aa = (T) new Integer(34); //unchecked cast warning
  }
}

But still I see the compile time warning regarding the unchecked casts in play. What is the scenario that JLS is trying to point to here?

theutonium.18
  • 483
  • 2
  • 7

0 Answers0