无论我做什么,当用户在控制台输入 1 时,这段代码永远不会评估为真......我很困惑为什么它评估为假......非常感谢任何帮助。
import java.io.*;
public class Default
{
public static void main(String [] args)
{
System.out.println("Welcome to the CS conversation game\n");
System.out.println("Choose your game\n1)Hex to Decimal\n2)Binary to Decimal");
Hex2Decimal PlayHex = new Hex2Decimal();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String GameSelection = null;
try
{
GameSelection = br.readLine();
}
catch (IOException ex)
{
ex.printStackTrace();
}
if(GameSelection == "1")
{
PlayHex.Play();
}
}
}