Consider the java code below. The output which i got is written after the //
class test { public static void main(String[] args) { int x=10; System.out.println("X="+10 == "X="+10); // TRUE System.out.println("X="+x == "X="+x); // FALSE } } In both the lines String concatenation is going to happen but how the output is different?
"X="+012or"X="+0b1010(just tested it)."X="+10can be evaluated at compile time."X="+xcannot.String", which is guaranteed to be interned.