This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Duplicate Method Compiler Error 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 » Beginning Java
Bookmark "Duplicate Method Compiler Error" Watch "Duplicate Method Compiler Error" New topic
Author

Duplicate Method Compiler Error

abin joy
Ranch Hand

Joined: Jul 29, 2008
Posts: 35
code
---------------------------------

class Test
{
public static void render(Shape s, Circle c)
{
System.out.println("render(Shape s, Circle c)");
}

public static void render(Circle c, Shape s)
{
System.out.println("render(Circle c, Shape s)");
}
}

----------------------------------
code

I expect this code to throw a duplicate method found compilation error?But its not throwing?I removed the arguments to both the functions and it immediatrely throws compiler error.Can anybody help me in this
[ September 10, 2008: Message edited by: abin joy ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

... because the methods have different argument lists? The order in which the arguments appear matters (of course).


[Jess in Action][AskingGoodQuestions]
Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
This is an example of function overloading.
 
Consider Paul's rocket mass heater.
 
subject: Duplicate Method Compiler Error
 
Similar Threads
Casting a extended class
static overloaded methods
inheritance question
Polymorphism Problem
polymorphism question