Consider the following snippet: Here I am trying to understand how to interpret these two statements Expression:1 Here we say that the List on the RHS must be such that all the elements of the list will satisfy the condition ? super List<? super Integer> but doubleList / integerList / numberList are not satisfying this condition anyhow – as we
Tag: jls
Unchecked Cast warning – shows up for Type parameters but not for Concrete types?
Consider the following snippet: From what I understand – whenever we convert Supertype -> Subtype Unchecked cast is flagged as the compiler does not know until the runtime if the type represented by the Supertype will ever match the SubType. Then over here – why is (Double) (Number)a not being flagged as the Unchecked Cast? Answer Unchecked cast is flagged
Where is the description of Constant Folding in the Java Language Specification, Java SE 11 Edition (JLS SE 11)?
As far as I know, Java deals with constant variables ยง4.12.4 by constant folding in compile time. I’ve tried my best, but I couldn’t find its description from JLS. Could anybody tell me where I could find official description of the constant folding process for Java 11? Answer The specification does not use the term Constant Folding. It has the
Why can’t we access static content via uninitialized local variable?
Take a look at below code: As you see while trying to access static field x via an uninitialized local variable Foo foo; code foo.x generates compilation error: Variable ‘foo’ might not have been initialized. It could seem like this error makes sense, but only until we realize that to access a static member the JVM doesn’t actually use the