This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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.
subject: doubt in method call
Similar Threads
Short initialize
JQ + Question ID :958011966030
Double and Float size
Surprising output,can't understood.
primitive widening doubt