eclipse does not insert @override annotation ? [message #1718074] |
Fri, 18 December 2015 22:50 |
Arthur Chan Messages: 44 Registered: September 2015 |
Member |
|
|
Hi.
I read that eclipse automatically adds the @override annotation when in the sub-class, a method or object from the superclass is overridden.
I haven't seen this behaviour from eclipse, yet.
Maybe I was given wrong info?
Can someone point to sample codes please?
P.S.:
Here is a contrived example,
class Animal{
public void move(){
System.out.println("Animals can move.");
}
public void grow(){
System.out.println("Animals can grow.");
}
}
class Dog extends Animal{
@Override // <- I added this annotation, not eclipse
public void move(){
System.out.println("Dogs can walk and run.");
}
public void bark(){
System.out.println("Dogs can bark.");
}
}
public class TestDog {
public static void main(String[] args) {
//
Animal a = new Animal();
Animal b = new Dog();
a.move();
b.move(); // executes the method in Dog class;
b.grow();
}
}
[Updated on: Fri, 18 December 2015 23:20] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07912 seconds