0
What exactly is the significance of 'override'
3 Respuestas
+ 4
Overriding replaces the implementation of the parent method. The parent method in this case being start() in the Machine class.
So, with your code, you created a new implementation of the method for that object in the anonymous inner class.
Had you of created a second object without using anonymous classes, the output would be: "Starting....".
@Override is an Anotation to indicate that you are in fact Overriding something.
If the method isn't Overriding something and you use the annotation, an exception will occur.
For good programming standards, always use the annotation.
To make things easier to read, I usually put the annotation on its own line.
Ex/
@Override
public void myMethod(){
}
+ 1
here is an example that you may want to check to see difference or understand the meanings of overriding and overloading https://code.sololearn.com/c0awDMpDLukF/?ref=app
0
https://code.sololearn.com/cbSfl04QVfVA/?ref=app
help me in this code answering my question