Reputation: 5028
The "The value of the local variable is not used" warning is really annoying as it hide breakpoints in the sidebar. The variable in question also gets underlined to highlight this warning so the sidebar icon is fairly redundant.
So is there any way to hide this warning in the sidebar?
Upvotes: 7
Views: 11051
Reputation: 6934
It will require a new build and it's done.
Of course, you must aware that you are ignoring that option and potentially increasing memory consumption and leaving clutter in your code.
Upvotes: 10
Reputation: 71
@SuppressWarnings("unused")
Add the above line of code before main() it will suppress all the warning of this kind in the whole program. for example
public class CLineInput
{
@SuppressWarnings("unused")
public static void main(String[] args)
{
You can also add this exactly above the declaration of the variable which is creating the warning, this will work only for the warning of that particular variable not for the whole program. for example
public class Error4
{
public static void main(String[] args)
{
int a[] = {5,10};
int b = 5;
try
{
@SuppressWarnings("unused") // It will hide the warning, The value of the local variable x is not used.
int x = a[2] / b - a[1];
}
catch (ArithmeticException e)
{
System.out.println ("Division by zero");
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Array index error");
}
catch(ArrayStoreException e)
{
System.out.println("Wrong data type");
}
int y = a[1] / a[0];
System.out.println("y = " + y);
}
}
Upvotes: 7