I'm using Java 8 with Android Studio and Retrolambda plugin to compile lambdas to anonymous classes (because Java 8 is not supported on Android). The IDE shows me warnings (or tips) how to change my code to use all the features of Java 8. One of these features is "Can be replaced with foreach call" when you loop over collection. I want to suppress this kind of warning, but I can't figure out how to do this.
The simplest solution to suppress this kind of warning is the @SuppressWarnings("all")
annotation. But I want to be warned about different types of warnings so this is not the solution.
Is there any way to disable this kind of warning for entire IDE or just for the code block (something like @SuppressWarnings("foreach")
)?
If you choose to put @SuppressWarnings("rawtypes") at the method level, Eclipse will suppress all raw-types warnings inside that method. If we compile same code without @SuprressWarnings, using javac compiler it will show the following hint: $ javac RawType.
The @SuppressWarnings annotation disables certain compiler warnings. In this case, the warning about deprecated code ( "deprecation" ) and unused local variables or unused private methods ( "unused" ).
Use of @SuppressWarnings is to suppress or ignore warnings coming from the compiler, i.e., the compiler will ignore warnings if any for that piece of code. 1. @SuppressWarnings("unchecked") public class Calculator { } - Here, it will ignore all unchecked warnings coming from that class.
One way is to configure your intention settings (I'm assuming this is doable with Android Studio, I'm an IntelliJ user).
For this specific intention:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With