The java source code is as below:
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);
}
}
If there is no “package test;” the corresponding class file will behave correct. But when I add “package test;” the exception as stated in the title occured. Is there something wrong?
Chances are you’re not building it properly or not running it properly.
Build it like this (filling in the path information appropriately):
Run it like this:
(You can change the output directory specified by
-dof course, at which point you should either add that directory to the classpath or change to that directory before running.)