Variable x is already defined in this method
Applies to:
NA
Description:
There is more than one declaration of the same variable in the same method
Cause:
The variable is declared more than once:
public void myTest()
{
int x = 0;
System.out.println(x);
int x = 8;
System.out.println(x);
}
JAVA-Compiler dy, how can i use int x and int y in java more than once?, is already defined in main java, java, java "is already defined in", java function alreay defined, java variable already defined, lrm-00118: syntax error at '=' at the end of input, variable already defined in main, variable already defined java, variable is already defined in a method, variable is already defined in main, variable x is already defined java, x is already defined in java, x is already defined in main, x is already defined in method?
Declare the variable only once in the same method.
Example:
public void myTest()
{
int x = 0;
System.out.println(x);
x = 8;
System.out.println(x);
}