File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why does this compile? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "why does this compile? " Watch "why does this compile? " New topic
Author

why does this compile?

Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531


how is (f<c) even compiling? arent they of different types?
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
is this because in an arithmetic operation the char will be promoted to float? i think this could be the reason...

please confirm
rohan yadav
Ranch Hand

Joined: Oct 13, 2009
Posts: 156
I think char is internally converted to float or int.


Sage of The Monstrous Toad of Mount Myoboku
Chintan B Shah
Ranch Hand

Joined: Sep 23, 2008
Posts: 83
I think "widening" happens here and "if" boolean expression would look something like this
if(9<97)

My 2 cents.

Thanks
Chintan.

SCJA 1.0
Hiruka Sandev
Greenhorn

Joined: Nov 22, 2009
Posts: 11
Internally a char is a 16 bit unsigned integer. So a char can be used in places where a integer literal could be used.
Dejan Miler
Ranch Hand

Joined: Nov 14, 2009
Posts: 56
First of all char is of integer type.
And secondly i agree with Ankur char will be promoted to float.

Dejan.


SCJP 1.6 in progress ....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why does this compile?