Error:
<variable> is already defined in <methodName>
Explanation:
You are providing a data type for a variable that has already been defined..
Checklist:
- Did you declare the variable earlier in your program? Data types should be given only the first time a variable name is used.
Example:
With the following statements in a source file named Input.java:
1 /* Input class */
2
3 public class Input
4 {
5 public static void main( String [] args )
6 {
7 int count;
...
10 int count = 0;
// more code here
the Java compiler would generate the following errors:
Input.java:10: count is already defined in main(java.lang.String[])
int count = 0;
^
The problem is that count was already declared on line 7.
To correct this problem, remove the data type from line 10 as in the following:
10 count = 0;