Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

On virtual machines and expected behaviour

Name: Anonymous 2010-05-17 19:44

Ever tried running this on your ENTERPRISE VIRTUAL MACHINE?
Integer a = 1000;
 Integer b = 1000;
 System.out.println("a == b (1000 == 1000): " + (a == b));

 Integer aa = 100;
 Integer bb = 100;
 System.out.println("aa == bb (100 == 100): " + (aa == bb));

Guess what's the output, run it and report back.

Name: Anonymous 2010-05-17 23:13

>>27
Answer: no.
All Java Objects, when attempted to be compared using simple binary logic, will always produce false.

One exception to this rule, as demonstrated by this thread, is a silly technicality with Integer that allows caching of an int value between -128 and 127.  However, this is the wrong way to initialize the Integer object and should be viewed as a curiosity.

>>30
Incorrect.
Trying to perform:
Integer a = new Integer(0);
Integer b = new Integer(0);
System.out.println("Result of binary operation: " + (a == b));

will produce the output:
Result of binary operation: false

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List