0

As the title hints at, I am wondering if I am able to use functionality in a class's constructor from another constructor (overload) of the same class in Java.

Hopefully this code demonstrates what I'm trying to achieve (ignore the fact that children gets overwritten, bad example in this case):

class Node {
    int[] value;
    ArrayList<Node> children;

    Node ()
    {
        this.children = new ArrayList<>();
    }

    Node (int[] value)
    {
        this.value = value;
        Node();
    }

    Node (int[] value, Node[] children)
    {
        this.children = new ArrayList<Node>(Arrays.asList(children));
        Node(value);
    }
}
Grzegorz Oledzki
  • 23,614
  • 16
  • 68
  • 106
James Middleton
  • 679
  • 1
  • 5
  • 8

0 Answers0