我有一个菜单驱动程序,其中提示用户输入尽可能多的整数,以构建二叉搜索树——我刚刚开始,一旦他们点击“Q”,就无法阅读他们的整数
switch(inputOption){
case 1:
System.out.println("You've selected to create a new binary tree." + "\n");
Scanner scan = new Scanner(System.in);
String again;
String tempInput;
Boolean repeat = true;
try{
System.out.println("Please enter as many integers as you'd like, hit 'Q' when you are finished." + "\n");
do{
tempInput = scan.next();
if(tempInput != "Q"){
integerInput = Integer.parseInt(tempInput);
repeat = true;
}
else
repeat = false;
}while(repeat);
}catch(InputMismatchException e){}
关于如何让它识别“Q”的任何想法?