Original address: http://blog.csdn.net/rznice/article/details/7105848
Key words
Deprecation
Unchecked
Fallthrough
Path
Serial
Finally
All
public class DeprecatedExample2 {
@Deprecated
public static void Foo () {
}
}
public class DeprecatedUser2 {
@SuppressWarnings (value={"deprecation"})
public static void Main (string[] args) {
Deprecatedexample2.foo ();
}
}
public class DeprecatedUser2 {
@SuppressWarnings ({"Deprecation"})
public static void Main (string[] args) {
Deprecatedexample2.foo ();
}
}
Import java.util.*;
@SuppressWarnings ({"Deprecation"})
public class Nongenerics {
@SuppressWarnings ({"Unchecked", "Fallthrough"})
public static void Main (string[] args) {
Runtime.runfinalizersonexit ();
List List = new ArrayList ();
List.add ("foo");
}
public static void Foo () {
List List = new ArrayList ();
List.add ("foo");
}
}
Have you noticed the unfamiliar annotations @Target and @Retention appended to the suppresswarnings annotation? These are called metadata annotations, and they describe where the annotation applies. I'll cover them in the second article in this series and explain how to apply metadata annotations to your own annotations.
The role of @suppressWarnings ("unchecked") in Java