0

MyProg.java:44:错误:类型不匹配:无法从 void 转换为 SearchTree

SearchTree nTree = nTree.insert(value);
                   ^^^^^^^^^^^^^^^^^^^

SearchTree.java:18:错误:类型不匹配:无法从 void 转换为 int[] value = Arrays.sort(value);

package ab12;
public class MyProg {
public static void main(String[] args) {
    QueueScheduler q = new QueueScheduler();
    int c = 0;
    for (int i = 0; i < 10; i++) {
        q.dynQueue[c].put(i);
        if (c == 2) {
            c = -1;
        }
        c++;
    }   
    Out.println("1. Random");
    Out.println(q.getRandom());
    Out.println(q.getRandom());
    Out.println(q.getRandom());
    Out.println("2. Priority");
    Out.println(q.getPriority());
    Out.println(q.getPriority());
    Out.println("3. RoundRobin");
    Out.println(q.getRoundRobin());
    Set set = new Set();
    Set other = new Set();
    String e = "Hallo";
    String e2 = "H.";
    String e3 = "red";
    String e4 = "blue";
    String e5 = "light";
    set.add(e);
    set.add(e2);
    set.add(e3);
    set.remove(e);
    other.add(e2);
    other.add(e3);
    other.add(e4);
    other.add(e5);
    set.union(other);
    set.difference(other);
    set.isSubsetOf(other);
    int value [] = new int[]{1, 3, 5, 7, 9, 13, 18, 19, 21};
    SearchTree nTree = nTree.insert(value);
    int s = nTree.sum();
    int num = nTree.numberOfLeafs();



     }
}
4

1 回答 1

0

该错误为您提供了所需的所有信息 - 您正在尝试将返回void的方法调用的结果分配给SearchTree. 该insert方法不会返回调用它的树。

我不确定你的意图到底是什么。如果您是SearchTree第一次声明,那么您将无法在同一语句中调用它的方法。

于 2013-01-21T19:03:14.007 回答