File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes why integer method is choosed and why string is choosed? 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 » Java » Java in General
Bookmark "why integer method is choosed and why string is choosed?" Watch "why integer method is choosed and why string is choosed?" New topic
Author

why integer method is choosed and why string is choosed?

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
here i am writing 2 programs with overloaded methods



here is the string problem



why int method is called why not long method?
and why String class is choosen when i have Object parameter ?


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

In the first instance writing literal value in your code will result in the values being an int. If you don't want this, signal that you don't, like this:

(just to make it clear, that is a lower-case L after the int value)

In the second case, primitive values cannot be null, so there is only really one method that can be called, i.e. the one that takes an Object as a parameter.
[ September 26, 2006: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by saikrishna cinux:
here i am writing 2 programs with overloaded methods

why int method is called why not long method?
and why String class is choosen when i have Object parameter ?


Well you must be satisfied with the answer of the first question.

For question Number # 2.

You must look at .

Choose the Most Specific Method.

This will helps you a lot ......I am quite sure.


The Best way to predict your future is to create it - Every great individual common man
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
Originally posted by Ankur Sharma:


Well you must be satisfied with the answer of the first question.

For question Number # 2.

You must look at .

Choose the Most Specific Method.

This will helps you a lot ......I am quite sure.


no ,sorry i couldn't able to understand it
can you please explain me more
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by saikrishna cinux:


no ,sorry i couldn't able to understand it
can you please explain me more


Could you please come up what you really not able to understand Question # 1 or Question # 2....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why integer method is choosed and why string is choosed?
 
Similar Threads
why it displays wrongly?
instanceof operator
Why mutable elements of Sets?
String Pool
Inheritance Question