public class Tester {
public static void main (
String[] args) {
int x = 5;
Integer x1 = x; Integer x2 = x;
int x3 = new Integer(5);
int x4=new Integer("5");
System.out.print(x1.equals(x));
System.out.print(x1 == x);
System.out.print(x2.equals(x1));
System.out.print(x2 == x1);
System.out.print(x2 == x3);
System.out.print(x2.equals(x3));
System.out.print(x4==x3);
// x4, x3 aren't in the pool because of "new" was used to create a fresh objects. So why this prints "true"?
}
}
OUTPUT: truetruetruetruetruetruetrue
So why "new" here doesn't create a new object for x3 and x4? ("true" printed for all!!!)
[ May 31, 2006: Message edited by: Firas Zureikat ]