JOptionPane.showMessageDialog死循环

来源:百度知道 编辑:UC知道 时间:2024/06/07 10:14:46
初学JAVA,写了个玩笑性质的小程序,当输入的数据为中文的时候,程序运行到结果之后陷入死循环,当输入的数据为字母、数字、符号的时候,程序运行完之后正常结束,请高手指点,感激不尽!以下是程序:
import java.util.*;
import javax.swing.JOptionPane;
class liulaoban2
{
public static void main(String[] args)
{
String input1=JOptionPane.showInputDialog(null,"请输入对碰之男主角名字");
String input2=JOptionPane.showInputDialog(null,"请输入对碰之女主角名字");
if(input1.indexOf("刘老板")>-1&&input2.indexOf("马老板娘")>-1)
{

JOptionPane.showMessageDialog(null,"本对男女配对指数:100%\n你们简直就是天上一对,地上一双\n绝配啊!");
}
else
{
Random rnd = new Random();
JOptionPane.showMessageDialog(null,"本对配对指数:"+rnd.nextInt(99)+"%");
}
}
}

搞个while(true)不就可以了
while(true){
JOptionPane.showMessageDialog(null,"本对男女配对指数:100%\n你们简直就是天上一对,地上一双\n绝配啊!");

}