@Override for method overriding

public class OverrideTest {
    public static void main(String[] args) {
        System.out.println(new OverrideTest().toString());
    }

    @Override public String tostring() { // should be toString()
        return "OverrideTest";
    }
}

If I compile this:

mkseo@mkseo:~/tmp$ javac OverrideTest.java
OverrideTest.java:6: method does not override a method from its superclass
    @Override public String tostring() {
     ^
1 error

Similar Posts:

Post a Comment

Your email is never published nor shared.