Sublime Forum

@Override Annotation not working, why?

#1

In sublime text 3,Im writing a program of method overriding…
when I don’t use “@Override”, the program will does not through any error, but when I using the
@Override” annotation it will show error, if program is correct…I facing this problem plz explain why? and what can I do for come out of this error

imp note : but the same program is running on other platforms while using “@Override” also

Program:

class Sample12
{
public void count(int num)
{
System.out.println(“This is count() in the Parent class”);
for(int i=1;i<=num;i++)
{
System.out.println(i);
}
}
}

class Demo12 extends Sample12
{
@Override
public void count(int num)
{
System.out.println(“This is count() in the Child class”);
for(int i=num;i>=1;i–)
{
System.out.println(i);
}
}

}

class My
{
public static void main(String[] args)
{
Sample12 s1 = new Sample12();
s1.count(5);
Demo12 d1=new Demo12();
d1.count(5);

}

}

Errors are coming like this:
.\Override.java:1: error: duplicate class: Sample12
class Sample12
^
.\Override.java:12: error: duplicate class: Demo12
class Demo12 extends Sample12
^
C:\Users\yuvar\Desktop\CDT3\My.java:15: error: cannot access Override
@Override
^
bad source file: .\Override.java
file does not contain class Override
Please remove or make sure it appears in the correct subdirectory of the sourcepath.
3 errors
[Finished in 1.3s]

0 Likes