Objective
The blog has been open for several years, always do not know what to write. Recently changed job interview, found that they have a lot of things will be used but can not say, because they do not summarize. So write a blog to record what you're going to do, and review it when you are free.
First, annotations
Annotations are new features added after jdk1.5, which can be understood as an identity that can be used in classes, methods, properties ... And so on, then we can handle the class that has the special identity.
jdk1.5 comes with 3 annotations, and you can customize annotations, and now common open source frameworks (Spring, struts2, MyBatis) also support annotation development.
Two, Java comes with three kinds of annotations
- < Span style= "color: #000000;" > @SuppressWarnings Suppress warnings, ignore warnings, tell the compiler with this identity: I want to write this, don't give me a warning!
public Class Test { // Remove the warning @SuppressWarnings ("unused" static void main (string[] args) { // This would warn: the variable is not used List List = new arraylist<string> ( ); }}
- @Deprecated used to mark a method obsolete
/** * @Deprecat Ed This method is obsolete, use the new Method xx () */ @Deprecated public void SayHello () {System.out.println (" This method is obsolete!) "); }
- @Override means to overwrite the method, and in eclipse if it is wrong, there will be an error message.
Interface testinterface{ void SayHello ();} class Implements testinterface{ @Override publicvoid SayHello () { System.out.println ("method overrides");} }
Java Annotations Learning (i) Preliminary understanding and simple use