Top "Jls" questions

The Java Language Specification is the definitive technical reference of the Java programming language.

How to create a class literal of a known type: Class<List<String>>

Take the following: public Class<List<String>> getObjectType() { // what can I return here? } What class literal …

java generics jls
Why no static methods in Interfaces, but static fields and inner classes OK? [pre-Java8]

There have been a few questions asked here about why you can't define static methods within interfaces, but none of …

java interface jls
If you overwrite a field in a subclass of a class, the subclass has two fields with the same name(and different type)?

I have 3 classes: public class Alpha { public Number number; } public class Beta extends Alpha { public String number; } public class Gama …

java subclassing jls
why Integer.MAX_VALUE + 1 == Integer.MIN_VALUE?

System.out.println(Integer.MAX_VALUE + 1 == Integer.MIN_VALUE); is true. I understand that integer in Java is 32 bit and …

java integer integer-overflow twos-complement jls
Is "public static final" redundant for a constant in a Java interface?

This code: interface Config { int MAX_CONN = 20; } compiled and worked as I expected. It looks like this is the same …

java interface static final jls
Why is x == (x = y) not the same as (x = y) == x?

Consider the following example: class Quirky { public static void main(String[] args) { int x = 1; int y = 3; System.out.println(x == (…

java variable-assignment equality operator-precedence jls
Case sensitivity of Java class names

If one writes two public Java classes with the same case-insensitive name in different directories then both classes are not …

java jvm jls
Order of execution of parameters guarantees in Java?

Given the following function call in C: fooFunc( barFunc(), bazFunc() ); The order of execution of barFunc and BazFunc is not …

java operator-precedence specifications jls
Return value of assignment operator in concurrent code

Given the following class: class Foo { public volatile int number; public int method1() { int ret = number = 1; return ret; } public int …

java concurrency variable-assignment jls
Annotation attribute must be a class literal? Why? Constants should be fine too

Can someone explain why String and Class annotation parameters are expected differently? Why does the compiler require literals for Classes, …

java testng jls