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);
}

admin JAVA-Compiler

  1. admin
    March 9th, 2009 at 18:22 | #1

    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);
    }

  1. No trackbacks yet.