java – @Override on Implementation

Will you put comments in the implementation class methods? Is it useful? If you input wrong or no input, it is a compilation error anyway

Solution

I assume you are asking about annotation methods defined in the implemented interface, or abstract methods in superclasses In this case, you are correct. Spelling errors in the method signature will lead to compilation errors, whether there is @ override However, I think annotations still help to explicitly mark methods as implementing interfaces If the interface changes, using the @ override annotation on all implementation methods can help determine which method signatures have changed and need to be updated

@H_ 502_ 12@

More importantly, as mklhmnn mentioned in his answer, if a method is deleted from the interface, the @ override annotation in the implementation class will lead to compilation errors Without comments, you may not realize that a method has been deleted from the interface, which may lead to subtle errors@ H_ 502_ 12@

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>