我是Java新手,我正在尝试制作一个Java应用程序,它要求您拼写“Java”,如果您拼写正确,它将输入“yes”,但是,它输入“no”,我做错了什么:
package quiz;
import java.util.Scanner;
public class quiz {
public static void main(String[] args) {
Scanner kirill = new Scanner(System.in);
System.out.println(kirill.next());
String kirill2 = "Java";
if (kirill.equals(kirill2)){
System.out.println("yes");
}else{
System.out.println("no");
}
System.out.println(kirill);
kirill.close();
}
}
运行代码:Java
爪哇
不
java.util.Scanner[delimiters=\p{javaWhitespace}+][position=4][match valid=true][need input=false][source closed=false][skipped=false][group separator=\,] [小数分隔符=.][正前缀=][负前缀=\Q-\E][正后缀=][负后缀=][NaN字符串=\Q?\E][无穷大字符串=\Q?\E ]