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 21:36

>>16
Backwards compatibility does explain why it was broken in the first place.
Java was designed as an Object Oriented language, but because of efficiency and adoption concerns (Purely OO languages were quite radical at the time) they took the safe route and decided to retain primitive types. They have been paying for this ever since.
The introduction of generic typing meant that companion classes needed to be created for each primitive type (Allowing primitives to be used for creating generic types is not feasible when considering type erasure among other things).
Thus, we finally arrive at autoboxing as a solution to the inconvenience caused by having to interchange between OO and primitive types.

How else would you have done it- all things considered?

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