The @SuppressWarnings
annotation tells the compiler to suppress the warning messages it normally shows 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.basic;
import java.util.Calendar;
import java.util.Date;
public class SuppressWarningsExample {
@SuppressWarnings(value={"deprecation"})
public static void main(String[] args) {
Date date = new Date(2021, Calendar.OCTOBER, 3);
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.
Latest posts by Wayan (see all)
- How do I create a table with multiple header in iText 8? - March 16, 2024
- How do I add Image to a Table in iText 8? - March 11, 2024
- How do I downgrade Android SDK emulator version? - February 12, 2024