Here's a piece of my code. I have a problem with the insertPoint method. I have an array that I need to name. In insertPoint method I give a String variable that gives the name to the method. But it won't take the name complaining "the type of the expression must be an array type but it resolved to string". I tried adding "Node name[]" but it gave me an error saying "dublicate local variable name". Not sure how to resolve this problem.
public class Node {
String name;
public void newArray(int number) {
this.name = "children" + number;
final Node name[] = new Node[4]; // Node's name should now be e.g. "children0"
insertPoint(this.x, this.y, size, this.name);
}
public void insertPoint(int x, int y, int size, String name) {
// Node name[]; // dublicate local variable name
if (this.x < c) {
if (name[0] == null) { // the type of the expression must be an array type but it resolved to string
name[0] = new Node(x, y, 0, 0, length);
} else {
newArray(0);
}
}
}
}