Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Ira Adams   on Oct 16 In Java Category.

  
Question Answered By: Eddie Austin   on Oct 16

The best way I know to solve that is (modifications are marked with
a '*':

public  void MyInt(){
*boolean continue = true; //Control variable
*while(continue){ //evaluate
> try{
> int1 = Integer.parseInt(JOptionPane.showInputDialog("type the
1
> number"));
> int2 = Integer.parseInt(JOptionPane.showInputDialog("type the
2
> number"));
> int3 = Integer.parseInt(JOptionPane.showInputDialog("type the
3
> number"));
> y = "";}
* continue = false; //if no problem was detected
> catch(java.lang.NumberFormatException x){
* continue = true; //if a problem was detected, making possible
* another cicle
> JOptionPane.showMessageDialog(null, "you have to make an
entry");}
> }

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Catching Exceptions Or get search suggestion and latest updates.


Tagged: