Java Java Data Structures Efficiency! Custom Serialization

shu Chan
shu Chan
2,951 Points

Can someone expalin to me what is @Override?

My understanding of this is that it tells the program it must run the code that is within it's scope as well as the default code it would run. Am I correct?

2 Answers

Mohammad Laif
Mohammad Laif
Pro Student 22,285 Points

If you have parent class contains printDateMethod(), and you create a new class extended that parent class. So you end up with child class and parent class.

Now using printDateMethod() in the parent class output -> "12-31-2017".

But in the child class you want to change that output to -> "31-12-2017", therefore you can change printDateMethod() code inside your child class, but you need to write "@Override" above it, to notify the compiler (so he did not freak out, wondering why the child behave different than his parent).

that @Override called annotation, and there are more of them!

Adding to what Mohammad said, I personally dont use the @Override line and everything works just fine. I believe it is used to make us "Better Programmers", thus allowing future programmers and developers who will take a look at our code will be able to understand that the method we've written is an override.