while(true){//你的程序System.out.println("再玩一次?");String st= scan.next();if( st=="y"){continue;}if( st=="n"){break;}System.out.println("既不是y也不是n,出错");}