aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Comparison and equality operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Comparison and equality operators" Watch "Comparison and equality operators" New topic
Author

Comparison and equality operators

meeta verma
Greenhorn

Joined: May 15, 2004
Posts: 19
I never thought we could compare (>,<,== ,!=) an
int with a double
or
double with long
or
long with float etc.

I thought the primitives should be of the same type for comparison.

Can someone throw some light on this......
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
There are conversions that take place during the evaluation of the expression. "Widening", etc. The language specification talks about it in detail. But simply put, most things will be "widened" to the greater number of bits required and then the evaluation will take place.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Comparison and equality operators
 
Similar Threads
Math question...
doubt regarding basic primitives
primitive widening doubt
Mock exam by sreenivasa kumar majji - Q6
Actual parameter checking