[2581] in java-interest
Re: Problems with Method names
daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Thu Oct 5 02:37:37 1995
Date: Wed, 4 Oct 1995 22:03:30 -0700
From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
To: sreenu@actor.cs.vt.edu
Cc: java-interest@java.Eng.Sun.COM
Hi Sreenu,
> Im having problems with method resolution in a sub-class.
>
> public class A {
> public void
> meth(someType) { code here }
> }
>
> public class B extends A {
> public void
> meth(someOtherType) { code here }
> }
>
> The compiler generates an error saying ambiguous methods since the two
> methods have the same name but different signature.
> Is this NOT allowed in Java?
It is allowed, but B.meth is not overriding A.meth because the
arguments are different. Java does not support contra/co-varient
typing of arguments in overloaded method.
Have fun,
Arthur van Hoff
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com