File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes method overloding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "method overloding" Watch "method overloding" New topic

method overloding

manohar reddy

Joined: Oct 13, 2007
Posts: 12
If we have two methods with the same name and same number and type of parameters with different return types. Which of the methods takes the precedence?
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

A method can't have the same method name, but different return type.

SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Olivier Legat
Ranch Hand

Joined: Nov 17, 2007
Posts: 176

You would simply get an error

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: method overloding
Similar Threads
Interface doubt
Private methods in super class
final methods
Private methods in EJBs cannot have transaction attributes