Detailed java built-in annotations

table of Contents

一、@Override

Two, @Deprecated annotation

Three, @SuppressWarnings


一、@Override

@Override is used to annotate methods to indicate that the annotated method is a method of overriding the parent class:

In order to support @Override, you need to upgrade the project project to 1.6 or above; if the Java code is no problem after the upgrade, but the project reports an error, you can solve it by right-clicking the project "Properties"——>"Project Facets"——> Select the corresponding version in the java item on the right and it will be OK.

Two, @Deprecated annotation

@Deprecated is used to indicate that the annotated element (member variable or method) is discouraged by programmers due to security issues or better choices. If it is used forcibly, the compiler will issue a warning. (Ie outdated, can be used but not recommended)

Note: Since it is outdated, there must be a new method to solve it. You can find a new method by entering the source code, generally in the comment above the method;

Three, @SuppressWarnings

@SuppressWarnings is used to cancel the warning displayed by the compiler . The common attribute values ​​of this annotation are as follows:

deprecation: Use program elements that have been marked by @Deprecated;

unused: The program contains unused elements;

serial: The serialVersionUID definition is missing on the serializable class;

Guess you like

Origin blog.csdn.net/m0_46383618/article/details/113528511