File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why integer method is choosed and why string is choosed?

 
saikrishna cinux
Ranch Hand
Posts: 689
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
saikrishna cinux
Ranch Hand
Posts: 689
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1249
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic