ANONYMOUS wrote:
Hi,
This can be seen as a general question or a question related to the assessed lab, but I was wondering about the appropriate uses of the @Override annotation.
Should we use @Override every time we try to override a method to catch errors, or is that unnecessary for some of the simpler methods? In other words, how do you determine when we should use the annotation before we override a method?
Also, are there any other annotations we should pay attention to, apart from @Override? Maybe I have terrible memory, but I don't recall us covering other relevant annotations in the unit so far. Thank you so much!
You do not need to use anything that we have not covered in the lectures, previous labs, or this lab sheet.
As was said in one of the lectures: The purpose of @Override
is to express your intent that this method should override one from the parent class, so the compiler can warn you if it does not, as that likely indicates an error. As Tin Chi says, if it is your intent to override a method, you should probably say as such.