From JLS- If two methods of a class (whether both declared in the same class, or both inherited by a class, or one declared and one inherited) have the same name but different signatures, then the method name is said to be overloaded. There is no required relationship between the return types or between the throws clauses of two methods with the same name but different signatures.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).

Hi Jason, >>Does it mean that it has the same name takes the same number of parameters and has the same return type? Yes, except for the return type. The signature is the method name and the list of parameters. Return type is not part of a method's signature. /rick

public class A { static void mm() {System.out.println("mm");} static void mm(int a) {System.out.println("mm");} } method mm() is static and we overloaded it. where is the problem. i am not sure if this is the question you were asking. methods can be overloaded. period. ( static or non-static ) or are you asking overriding, then also it is fine class B extends A { static void mm() {System.out.println("mm-overriding");} } method mm() is overridden in class B and is ok. so again methods can be overridden (static or non-static)

public class A { static void mm() {System.out.println("mm");} static void mm(int a) {System.out.println("mm");} } method mm() is static and we overloaded it. where is the problem. i am not sure if this is the question you were asking. methods can be overloaded. period. ( static or non-static ) or are you asking overriding, then also it is fine class B extends A { static void mm() {System.out.println("mm-overriding");} } method mm() is overridden in class B and is ok. so again methods can be overridden (static or non-static)

Static methods don't participate in overriding, in the example you have shown the method mm() is not being overridden, if you read the JLS part that Ajith has pointed out, you will understand it. Vanitha.

Hi Mark. You're right about being able to *overload* static methods; there is no problem there. But you cannot override static methods; they are *not* inherited by an object, they reside with a class. If you redefine a static method in a subclass with the same signature as in it's super-class, you have not overriden it, you have "Hidden" it. See JLS 8.4.6.2 Here's an example program I hope makes this clear:

yes the terminology for static methods is not overridden. Don't get me wrong here but i was just trying to put the point across. But you would agree that it is just mere words that we define hide or shadowing instead of overriding. right ?

Originally posted by Vanitha Sugumaran:

Static methods don't participate in overriding, in the example you have shown the method mm() is not being overridden, if you read the JLS part that Ajith has pointed out, you will understand it. Vanitha.

But you would agree that it is just mere words that we define hide or shadowing instead of

I for one don't want to accept that these are just mere words. Sorry to disagree. You hide or shadow by making them private or protected or package level access. But you are....overriding to change the behavior of something. Having said that I would argure in favor of the fact that the word overriding used on static or private methods doesn't make sense and so would not argue about that. Neither argument wins. For what its worth..... - satya [ January 08, 2002: Message edited by: Madhav Lakkapragada ]