-------------------------------------- Java Sag is under construction: What is SuppressWarnings annotation?
Please inform us if you find a non good advertisement : info.enim dot gmail.com

Best Web Hosting

dimanche 6 mai 2012

What is SuppressWarnings annotation?

The @SuppressWarnings annotation tells the compiler to suppress the warning messages it normally show during compilation time. It has some level of suppression to be added to the code, these level including: all, deprecation, fallthrough, finally, path, serial and unchecked.
package org.kodejava.example.annotation;

import java.util.Date;

public class SuppressWarningsExample {
    @SuppressWarnings(value={"deprecation"})
    public static void main(String[] args) {
        Date date = new Date(2008, 9, 30);

        System.out.println("date = " + date);
    }
}


In the example above if we don't use @SuppressWarnings annotation the compiler will report that the constructor of the Date class called above has been deprecated.

Aucun commentaire:

Enregistrer un commentaire

Best Web Hosting