0

java源代码如下:

package test;

public class DotMain {
    public static void main(String... args) {
        String s1 = "abcdex";
        String s2 = "ac";
        boolean[] r1 = new boolean[26];
        for (char c : s1.toCharArray())
            r1[c - 'a'] = true;
        boolean contained = true;
        for (char c : s2.toCharArray()) {
            if (!r1[c - 'a']) {
                contained = false;
                break;
            }

        }
        System.out.println(contained);
        System.out.println(s1 + s2);
    }
}

如果没有“包测试”;相应的类文件将表现正确。但是当我添加“包测试;” 发生了标题中所述的异常。有什么不对?

4

1 回答 1

1

Chances are you're not building it properly or not running it properly.

Build it like this (filling in the path information appropriately):

javac -d . path/to/DotMain.java

Run it like this:

java test.DotMain

(You can change the output directory specified by -d of course, at which point you should either add that directory to the classpath or change to that directory before running.)

于 2012-07-27T10:24:45.927 回答