It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes doubt in method call 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 "doubt in method call" Watch "doubt in method call" New topic

doubt in method call

Carlos G�mez
Ranch Hand

Joined: Sep 06, 2006
Posts: 56
hi ranchers

somebody could i tell me, why prints float i in the next code ?
i don't understand which is the rule ?

SCJP 1.4, 1.5 In progress
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
5.3 Method Invocation Conversion

"4" is int constant.
Carlos G�mez
Ranch Hand

Joined: Sep 06, 2006
Posts: 56
thank you wise
Santhosh Raje

Joined: Sep 26, 2006
Posts: 9
Here there are two methods one takes short while other one takes float,
Since we passed a int value ,the method with float argument is taken and printed float.
Since For Short you know that 16 bit is the range while for float it is 64bits.
Assigning Wider Conversion is allowed ,while Narrowing the conversion then we need to use casting for it.
I agree. Here's the link:
subject: doubt in method call
jQuery in Action, 3rd edition