my dog learned polymorphism
The moose likes Java in General and the fly likes regarding long and float Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "regarding long and float" Watch "regarding long and float" New topic
Author

regarding long and float

saxena neera
Greenhorn

Joined: Apr 21, 2012
Posts: 10
i was developing the below code....




Both results in output float, float , what the reason behind that please advise and how can I call double please advise thanks a lot..!
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8661
    
  23

saxena neera wrote:Both results in output float, float , what the reason behind that please advise and how can I call double please advise thanks a lot..!

I suggest you look here.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Vinod Vijay
Ranch Hand

Joined: Sep 13, 2011
Posts: 146

saxena neera wrote:i was developing the below code....





Both results in output float, float , what the reason behind that please advise and how can I call double please advise thanks a lot..!


Both are returning different string objects because you are returning string only. Method parameters have nothing to do here in this case. they are not doing any job. Period


Vinod Vijay Nair
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42956
    
  73
Vinod Vijay wrote:Method parameters have nothing to do here in this case. they are not doing any job.

I think you misunderstood the issue at hand. It is entirely about method parameters, and in particular, their type. It hinges on the fact that the parameter that fits most closely is chosen, and for a long, that is float, not double.

One way to achieve this would to call the method like this: m((double) b1)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding long and float
 
It's not a secret anymore!