这是我的代码到目前为止。我被困住了,我不知道该怎么做。谢谢您的帮助!创建静态方法来比较char和char两个字符串。如果字符串a中的所有字母都在字符串b中,则返回true。否则,返回false
public static boolean checkWord(String a, String b){
int x = 0;
while (x < a.length()){
int y = 0;
while (y < b.length()){
if(a.charAt(x)==b.charAt(y)){
String t = "next";
System.out.println(t);
y++;
}else{
}
}
x++;
}
return false;
}
想想你的代码中使用'break'。如果在第二个字符串中找不到字符,则应立即返回false。否则在结尾处返回true。 – ogzd