/*
* Annotation(正确覆写)
*/
class Book {
@Override
public String toString() {
return "《Java》";
}
}
public class Demo {
public static void main(String[] args) {
System.out.println(new Book());
}
}
/*
* Annotation(过期声明)
*/
class Book {
@Deprecated
public void fun() {
}
}
public class Demo {
public static void main(String[] args) {
Book book = new Book();
book.fun();
}
}
/*
* Annotation(压制警告)
*/
class Book<T> {
private T title;
public void setT(T title) {
this.title = title;
}
public T getT() {
return this.title;
}
}
public class Demo {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) {
Book book = new Book();
book.setT("Java");
}
}