Re: [Java Spec Report] JSR 201 autobox comments

"Christopher Sahnwaldt" <[email protected]> Wed, 07 Apr 2004 13:47:01 +0200
Newsgroups gmane.comp.java.spec-report
Organization http://freemail.web.de/
Message-ID <[email protected]>
Eric Blake [email protected] wrote:
> Was it an inadvertant error that 15.20.1 was specified (<, <=, >, >=) but not 
> 15.21 (==, !=)?  In other words, why can I say "1 < new Integer(2)" but not "1 
> != new Integer(2)"?
My guess would be that with the greater than / less than operators, it is always
clear that the primitive type has to be used, while the ==, != operators apply
to both primitive and reference types and it would be unclear which kind of 
comparison should be used. 

I haven't looked into autoboxing yet, but I guess given

Integer FIVE = new Integer( 5 );
Integer SIX = new Integer( 6 );

one could write

if( FIVE < SIX )...

That's cool, but

if( FIVE != SIX )...

would be kind of confusing.

Cheers, 
Christopher.



To unsubscribe from this mailing list, send an email to:
[email protected]
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/java-spec-report/

<*> To unsubscribe from this group, send an email to:
     [email protected]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/