java - try/exception for integer or double or string -


how differentiate integer , double. example if wanted integer , verify it. if integer output "you correct" else "you entred wrong. try again".

import javax.swing.*;  public class inputexceptions {      private static int inputint;     private static double inputdouble;      public static int inputint() {          boolean inputok = false;         while (inputok == false) {             inputint = integer.parseint(joptionpane.showinputdialog("enter integer"));              try {                  inputok = true;             } catch (exception e) {                 joptionpane.showmessagedialog(null,"*** error: value entered not integer ***");              }          } return inputint;     }      public static void main(string[] args) {         joptionpane.showmessagedialog(null,"*** integer correct input: " + inputint() + " ***");      }  } 


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -