In my source code for a mathematical project and I'm running into a problem that ends with a duplicate variable names error. In my function I take a string as an argument to be the name of a new array that will be allocated. Here's what the source code looks like
Code:
private static void somefunction(String name) {
int name[] = new int[10];
...
}
I need to call that function at least twice and I think that the compiler is getting confused and tries to allocate an array by the name of name instead of the string I provide as an argument. When it gets called the second time it tries to allocate name[] again and javac raises the error.
Does anyone know how I could tell Java to name the array what I provide as an argument?
Recent comments
7 hours 37 min ago
8 hours 37 min ago
12 hours 23 min ago
13 hours 38 min ago
17 hours 14 min ago
1 day 29 min ago
1 day 9 hours ago
1 day 10 hours ago
2 days 1 hour ago
2 days 4 hours ago