三叉树实现错误

Error in ternary tree implementation

我正在尝试实现三叉树,但出现以下错误,我不确定是什么问题,因为我的构造函数需要整数输入。

错误:

Trenarytree.java:46: error: constructor Trenarytree in class Trenarytree cannot be applied to given types;
    Trenarytree tree = new Trenarytree(1); 
                       ^

必需:无参数 发现:整数 原因:实际和形式参数列表的长度不同 1 个错误

代码:

import java.io.*;
import java.util.*;

public class Trenarytree {

public int y = 0;
public int count = 0;
private static Node root;

public void Trenarytree(int data)
{
    root = new Node(data);
}

public void add(Node parent, Node child)
{
    if (parent.getLeft() == null)
    {
        parent.setLeft(child);
    }
    else if (parent.getMiddle() == null){
        parent.setMiddle(child);
    }
    else
    {
        parent.setRight(child);
    }
}

public Node sum(Node z){
    if (z.getLeft()!=null) y++;
    if (z.getRight()!=null) y++;
    if (z.getMiddle()!=null) y++;
    if (y % 2 ==0){
        count++;
    y=0;};
}

public static void main(String[] args) {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
    Scanner sc = new Scanner (System.in);
    int M = sc.nextInt();
    int N = sc.nextInt();
    int k, l;
    Node[] array;
    Trenarytree tree = new Trenarytree(1); 
    array[1] = new Node(1);
    for (int i = 0; i < N; i++){
        k = sc.nextInt();
        l = sc.nextInt();
        array[k] = new Node(k);
        if (i==1) tree.add(root, array[k]);
            else tree.add(array[l], array[k]);

    }
}
}

class Node {
private int key;
private Node left;
private Node right;
private Node middle;

Node (int key) {
    this.key = key;
    right = null;
    left = null;
    middle = null;
}

public void setKey(int key) {
    this.key = key;
}

public int getKey() {
    return key;
}

public void setLeft(Node left) {
    this.left = left;
}


public Node getLeft() {
    return left;
}

public void setMiddle(Node middle) {
    this.middle = middle;
}

public Node getMiddle() {
    return middle;
}
public void setRight(Node right ) {
    this.right = right;
}

public Node getRight() {
    return right;
}

}

这是虚空:

public Trenarytree(int data)

有它就是方法,没有它就是构造函数

从构造函数 Trenarytree 定义中删除 void。构造函数不应该 return 任何东西,它们 return 构造对象。