How to repeat something until correct input is given in java?

后端 未结 2 1576
野趣味
野趣味 2021-01-26 00:58

I am trying to make a application and for one part of the application I need to get a input from the user stating how many times there click their mouse in 1 second. I want the

2条回答
  •  盖世英雄少女心
    2021-01-26 01:40

    An example as requested:

    int mouseClick;
    
    do {
        String str = JOptionPane.showInputDialog("Write down how many times you can click your mouse button in 1 second");
        mouseclick = Integer.parseInt(str);
    }
    while (mouseclick < 1 || mouseclick > 10);
    

提交回复
热议问题