0
我似乎得不到這回來的結果,它總是崩潰。我知道如何阻止它崩潰,只是沒有得到它。 Eclipse告訴我userIn從不關閉。如果你能告訴我我出錯的地方,將不勝感激。使用用戶輸入
import java.util.Scanner;
public class Translator {
public static void main(String[] args){
Scanner userIn = new Scanner(System.in);
System.out.println("Word?");
String word;
word = userIn.nextLine();
if(word == "Pollo"){
System.out.print("Pollo - Chicken");
}if(word == "Bien"){
System.out.print("Bien - Good");
}if(word == "Alto"){
System.out.print("Alto - Tall");
}
}
}
*您當前比較的對象,而不是字 –