0
public class HierarchyNode {

    public HierarchyNode parent;
    public Account node;
    public List children;

    HierarchyNode(Account acc, HierarchyNode parent) {
        this.parent = parent;
        this.node = acc;
        this.children = new List();
    }
}
1

Obvious answer, answering it for second time!!

Hope your question doesn't get deleted this time ;)

public class HierarchyNode {

    public HierarchyNode parent;
    public Account node;
    public List<HierarchyNode> children;

    HierarchyNode(Account acc, HierarchyNode parent) {
        this.parent = parent;
        this.node = acc;
        this.children = new List<HierarchyNode>();
    }
}
1
  • 1
    To be ruthlessly specific, this was a syntax error in the declaration of a List. From the documentation on Lists, the syntax for declaring a list is either <type name>[] <variable name> (i.e. String[] myStringList) or List<<type name>> <variable name> (i.e. List<String> myStringList). As public List children does not conform to either of those forms, an error was thrown. Adding the type of the things stored inside the list (inside angle brackets) resolves the error. – Derek F Jan 25 '17 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.