Now, my question is: What happens to the "Hello" created in the pool?
Is the same one used for the other string references too? (s1 and s2)??
I don't think so, wanted to confirm.
I think there are 2 string objects in the pool and 1 in the heap.
All exceptions that are subclasses of RuntimeException are UNCHECKED, which means they are not being checked by the compiler whether you have followed the handle-or-declare rule.
All exceptions that are subclass of Exception but not of RuntimeException are checked exceptions (meaning, they are being checked by the compiler whether you have followed the handle-or-declare rule.)
two instances of the
following wrapper objects will always be == when their primitive values are the same:
* Character from \u0000 to \u007f (7f is 127 in decimal)
* Short and Integer from -128 to 127
Integer as = 303;
System.out.println(as==lo); // Line 1
The compiler will throw error in line 1 as compiler cannot unbox Integer and Type case it to Long at the same time.
"," Use locale-specific grouping separators....
The format() and printf() methods were added to java.io.PrintStream in Java 5. These two methods behave exactly the same way, .....