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
17 hours 4 min ago
22 hours 2 min ago
23 hours 29 min ago
1 day 22 min ago
1 day 2 hours ago
1 day 6 hours ago
1 day 7 hours ago
1 day 9 hours ago
1 day 22 hours ago
2 days 18 min ago