• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java 1.5 Autoboxing parameters  RSS feed

 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this code:



Why doesn't the 5 get autoboxed into an Integer wrapper? (Well, at least in Java 1.5 beta 2 it don't)

[Update: seems that this could be a problem with the IDE Eclipse 3.1M1 I'm using]
[ August 25, 2004: Message edited by: Barry Gaunt ]
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why you not compile ???

I'm tested in my computer , it work fine...


please post your error...
[ August 25, 2004: Message edited by: somkiat puisungnoen ]
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Autoboxing surprises here
http://jroller.com/comments/eu/Weblog/autoboxing_surprises#comments
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Barry Gaunt,
I can successfully compile your code as well, using JDK 5.0 beta 2...

I'm afraid you are still using beta 1? :roll:
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:
Autoboxing surprises here
http://jroller.com/comments/eu/Weblog/autoboxing_surprises#comments


The link got very interesting topic for me... I was amazed of the following in the link...


Integer j1 = 127;
Integer j2 = 127;
System.out.println( j1==j2); //Works!!!

Integer k1 = 128;
Integer k2 = 128;
System.out.println( k1==k2); //Doesn't Work!!!

Integer w1 = -128;
Integer w2 = -128;
System.out.println( w1==w2); //Works!!!

Integer m1 = -129;
Integer m2 = -129;
System.out.println( m1==m2); //Doesn't Work!!!


Thanks for your great info, Pradeep...
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please do a

java -version

Just to make sure that you are using the Tiger.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ko Ko,
Be prepared for surprises when you use Tiger.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm actually compiling this program with Eclipse SDK 3.1M1 set up to use the Java 1.5 beta 2 and jre. And its complaining with the error message:
The method add(int, Integer) in the type List<Integer> is not applicable for the arguments (int)Template1.java



However, due to the vigourous responses to my query, I went back to trying it from the command line and lo' and behold it works. So that points to a problem with Eclipse SDK 3.1M1.

Thanks
-Barry

PS Looks like Eclipse uses its own compiler, and it's not up to full complience with Java 1.5 yet. Bleeding Edge Early Adopters beware.
[ August 25, 2004: Message edited by: Barry Gaunt ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!