What am I doing wrong here. These classes in 3 separate files, compile:
// SuperValue.java
public enum SuperValue { A, B; }
// Super.java
public abstract class Super {
abstract SuperValue method();
}
// Sub.java
public class Sub extends Super {
public SuperValue method() { return SuperValue.A; }
}
but, if I put them in packages:
// test/SuperValue.java
package test;
public enum SuperValue { A, B; }
// test/Super.java
package test;
public abstract class Super {
abstract SuperValue method();
}
// test/sub/Sub.java
package test.sub;
import test.SuperValue;
import test.Super;
public class Sub extends Super {
public SuperValue method() { return SuperValue.A; }
}
javac complains that Sub is not abstract and does not override method method.
Manish Pandit - 14 Sep 2006 04:10 GMT
Hi Frank,
This is because the abstract method you declared is default (package)
scoped. It is not visible outside the current package. If you change
the signature from
abstract SuperValue method();
to public abstract SuperValue method();
it will compile and work fine.
-cheers,
Manish