The role of @suppressWarnings ("unchecked") in Java

Source: Internet
Author: User

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

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.