0

我尝试使用 Tester 调用同一包的 CommandHandler 类的方法,它返回以下错误:

Tester.java:6: error: cannot find symbol
                CommandHandler.breakCommand("start Pandora");
                ^
  symbol:   variable CommandHandler
  location: class Tester

有任何想法吗?

package com.netbin.tools;

public class Tester {
    public static void main(String[] args) {

        CommandHandler.breakCommand("start Pandora");

    }
}

package com.netbin.tools;

import java.util.*;

public class CommandHandler {

    public static void breakCommand(String cmd) {
        ArrayList<String> cmdArray = new ArrayList<String>(); //  creates an array to fill
        int lastIndex = 0;
        for (int i = 0; i < cmd.length(); i++) {
            if(cmd.charAt(i) == 32) {
                cmdArray.add(cmd.substring(lastIndex, i)); // adds the thing...
                lastIndex = i+1;
            }
        }
        System.out.println(cmdArray);
    }
}
4

0 回答 0