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:08

>>30
That doesn't mean it's undefined, that means it just compares the references like it does for any other object. It still returns true or false (usually false). Jesus fucking Christ.

The problem is that it should be part of the language specification that it returns true if the integers are equal, or that it should compare by reference even if the value is in the -127 to 128 range. Consistency.
Since the former change can be made without breaking backward compatibility and the latter probably can't, it should be the former.

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