Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantage of @SuppressWarnings annotation

Tags:

java

@SuppressWarnings annotation is for cleaner code or by adding it is there any performance gain or any advantage ?

or can we reduce compile time by doing so.

like image 968
someone Avatar asked Dec 19 '22 04:12

someone


1 Answers

The @SuppressWarnings annotation type allows Java programmers to disable compilation warnings for a certain part of a program (type, field, method, parameter, constructor, and local variable). Normally warnings are good. However in some cases they would be inappropriate and annoying. So programmers can choose to tell the compiler ignoring such warnings if needed.

There is no relation with performance.

The developer who wrote the code knew that it was always going to be safe, decided to use @SuppressWarnings("unchecked") to suppress the warning at compilation.

As mentioned by others, it is just a trust between the developer and code written.

more info here and here

like image 180
Ankur Singhal Avatar answered Dec 30 '22 18:12

Ankur Singhal