0

When we create ArrayList such

 ArrayList<String> obj = new ArrayList<String>();

We are creating a ArrayList of type String and a reference to this object by the name obj. What about this?

 ArrayList<Node> obj;

A ArrayList of type Node with only the reference that is pointing to null? What does this statement look like in memory?

Example:

import java.util.List;

public class PackageNode {

private String value;

private List<PackageNode> children;

public PackageNode(String value) {

this.value = value;

}

public String getValue() {

return value;

}

public void setValue(String value) {

this.value = value;

}

public List<PackageNode> getChildren() {

return children;

}

public void setChildren(List<PackageNode> children) {

this.children = children;

}


}

Assume the code above is a Node class for a PackageTree, What does this mean?

List<PackageNode> children;
Armin
  • 89
  • 7

0 Answers0