Which modifiers can be used with local variables?

class Variable10
{
public static void main(String[] alt)
{
public int x=10;
System.out.println(x);
}
}
/*
Output:- CE[illegal start of expression]
Explanation:- For local variables only one modifier can be used that is "final". Except "final"
modifier if we are using any other modifier with local variables then we will get
compilation error.
All the following statements will rise compilation error:-
public int x=10;
protected int x=10;
private int x=10;
static int x=10;
abstract int x=10;
native int x=10;
transient int x=10;
volatile int x=10;
strictfp int x=10;
synchronized int x=10;
*/

0 comments: