我的第二个扫描仪输入按需要存储,但仍然没有执行比较 correctString == stringValue 的 if 条件。你能帮忙吗。
{
static String stringValue = "A";
public static void main(String[] args) {
int time;
time = speedType();
//System.out.println(time);
}
private static int speedType() {
System.out.println("Let's play a game\nHow fast can you type \"I type very quickly\" \nPress Enter then type the statement and then press Enter again");
Scanner scanner = new Scanner (System.in);
String string = scanner.nextLine();
if(string.equals("")){
Date startTime = new Date();
System.out.println("Start:\n");
String correctString = scanner.nextLine();
System.out.println(correctString);
if (correctString == stringValue){
Date endTime = new Date();
System.out.println(endTime);
}
else
System.out.println("Please enter correct string");
}
return 0;
}}