Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Duplicate Method Compiler Error

 
abin joy
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... because the methods have different argument lists? The order in which the arguments appear matters (of course).
 
Brij Garg
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is an example of function overloading.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic