Integer x = Integer.valueOf("10");
Integer y = Integer.valueOf("10");
System.out.println(x == y);What is the output, assuming default JVM settings?
Integer x = Integer.valueOf("10");
Integer y = Integer.valueOf("10");
System.out.println(x == y);What is the output, assuming default JVM settings?
true
false
NumberFormatException
Compilation error
Correct answer
true
`Integer.valueOf()` caches values from -128 to 127. Since 10 is within that range, both calls return the same cached instance, so `x == y` is `true`.