How to Use @SuppressWarnings annotation in Java


This example is to show how to use @SuppressWarnings annotation to avoid compiler warnings in Java.

Source Code

package com.beginner.examples;

public class SuppressWarningsExample {
     
    @SuppressWarnings("all")
    public static void main(String[] args){
         
        int a = 1;// a is unused
        System.out.println("OK");
    }
}

Output:

OK
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments