当我键入存储在字符串变量b
中的内容p
时,它不会响应,直到我多次单击回车键。
在这一点之后,程序只打印出 else 语句中的内容。程序响应的唯一字符串变量是j
.
编码:
package legit;
import java.util.Scanner;
public class Gamee {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String j = "good, how are you?";
String b = "good";
String p = "bad";
System.out.println("Hello, my name is Julie the Robot");
System.out.println("How Are You?");
if (j.equals(sc.nextLine())) {
System.out.println("Im Doing Great!");
}else if (b.equals(sc.nextLine())) {
System.out.println("Thats Great! :)");
}else if (p.equals(sc.nextLine())){
System.out.println("Thats not good");
}else {
System.out.println("I see...");
}