Home > Back-end >  Annotations SuppressWarnings (" unchecked ")
Annotations SuppressWarnings (" unchecked ")

Time:04-03

I have a T type is assigned to the Object of statement, was reported to the warning, then the compiler hint I add a note, warning, this annotation is dedicated to solve this kind of warning?
Object=(T) object. GetClass () getDeclaredConstructor (). The newInstance ();

CodePudding user response:

"In Java, no warning we should not handle (choose to use the third annotation methods ignore the warning is also considered to be a way to handle it, but there is no choice, three ways are considered to be no processing), while using the @ SuppressWarnings to ignore the running effect is the same, because, this is a very good coding habits, warning would sometimes cause some unexpected problems, so we should deal with all the warnings in the code, for indeed can ignore the warning, the JDK provides the annotations to markup code warning line, thus can make our code logic more tightly, because we dealt with each a warning,"
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Copyright statement: this article to CSDN blogger (DayDayUp,) the original articles, follow BY CC 4.0 - SA the copyright agreement, reproduced and this statement, please attach the original source link
The original link: https://blog.csdn.net/songzehao/article/details/82975186

CodePudding user response:

Quote: refer to 1st floor DayDayUp, reply:
"in Java, no warning we should not handle (choose to use the third annotation methods ignore the warning is also considered to be a way to handle it, but there is no choice, three ways are considered to be no processing), while using the @ SuppressWarnings to ignore the running effect is the same, because, this is a very good coding habits, warning would sometimes cause some unexpected problems, so we should deal with all the warnings in the code, for indeed can ignore the warning, the JDK provides the annotations to markup code warning line, thus can make our code logic more tightly, because we dealt with each a warning,"

But the casting can't deal with it
  • Related