• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in method call

 
Carlos G�mez
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
5.3 Method Invocation Conversion

"4" is int constant.
 
Carlos G�mez
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you wise
 
Santhosh Raje
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic