36th: Insist on using the override annotation

Source: Internet
Author: User

@Override annotations can only be used in a method declaration, which means that the annotated method declaration overrides a declaration in the super-type.

@Target (Elementtype.method) @Retention (Retentionpolicy.source)  public @Interface  Override {}

@Target the specified annotation only works on the method

@Retention specifies that annotations will be discarded at compile time

You should use the override annotation in each method declaration that you want to overwrite the superclass declaration so that when the method you want to overwrite is not overwritten, the compiler can prompt the error, greatly reducing the likelihood of the method overwriting the failure.

36th: Insist on using the override annotation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.