I have the following class which extends JFrame
@SuppressWarnings("serial")
public class View extends JFrame{
//bla bla bla bla code
}
Now I have the following sub class:
public class Foo extends View{
//bla bla bla bla
}
In the View
class Eclipse is giving me a warning so I added SuppressWarnings to get rid of it.I thought that by doing this I wouldn't have to retype SuppressWarnings in the Foo class but as it seems eclipse is giving me a warning on Foo class.Should this be happening?
@SuppressWarnings is an example of an annotation in Java. What you want is to let Foo inherit the annotations of View.
However, that's not possible in Java. This question is describing why it's not possible (namely because otherwise multiple-inheritance could occur as interface methods can have annotations as well.
When Eclipse is giving you a warning you should not ignore it generally. Try to make Eclipse happy because it only warns you if it has a very good reason to do so. If you're really confident that in your program a SuppressWarnings is suitable, then all subclasses must use that same annotation as well.