为什么会有Exception in thread "main" java.util.NoSuchElementException 20
importjava.util.Scanner;publicclasscontain{publicstaticclassstr{publicStringstr1;publ...
import java.util.Scanner;
public class contain {
public static class str {
public String str1;
public CharSequence str2;
public str() {
}
public void setStr1(String str1) {
this.str1 = str1;
}
public void setStr2(String str2) {
this.str2 = str2;
}
public void comStr() {
if (str1.contains(str2)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
str[] s = new str[3];
for (int i = 0; i < 3; i++) {
s[i] = new str();
s[i].setStr1(sc.next());
s[i].setStr2(sc.next());
}
for (int i = 0; i < 3; i++) {
s[i].comStr();
}
}
}
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:855)
at java.util.Scanner.next(Scanner.java:1364)
at Main.main(Main.java:46) 展开
public class contain {
public static class str {
public String str1;
public CharSequence str2;
public str() {
}
public void setStr1(String str1) {
this.str1 = str1;
}
public void setStr2(String str2) {
this.str2 = str2;
}
public void comStr() {
if (str1.contains(str2)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
str[] s = new str[3];
for (int i = 0; i < 3; i++) {
s[i] = new str();
s[i].setStr1(sc.next());
s[i].setStr2(sc.next());
}
for (int i = 0; i < 3; i++) {
s[i].comStr();
}
}
}
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:855)
at java.util.Scanner.next(Scanner.java:1364)
at Main.main(Main.java:46) 展开
2个回答
展开全部
具体异常信息贴出来
追问
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:855)
at java.util.Scanner.next(Scanner.java:1364)
at Main.main(Main.java:46)
谢谢!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询