@SuppressWarnings annotation
7 March 2008In this post, I will be talking briefly about SuppressWarnings annotation.
Java compiler gives you warnings to assure that you know what is happening. Sometimes, you want don’t want the warnings. Java 5.0 provides a way for this.
One had to use SuppressWarnings annotation to ignore the warnings. Annotations are followed by @.
For example: consider the following code:
int a; Object object = new Object();
I declared two variables and did nto use them in my code. When I compiled the code, I got 2 warnings:
The local variable a is never read The local variable object is never read </pre >. To remove the warnings, I will use the @SuppressWarnings annotation. <pre lang="java"> @SuppressWarnings("unused") Object object = new Object(); @SuppressWarnings("unused") int a;
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: @SuppressWarnings annotation