wood burning stoves
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

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

My 2 cents.


SCJA 1.0
Hiruka Sandev

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.


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