vendredi 18 septembre 2015

How can I check if my string is other than int's, to clarify i need to check it is not a number

... if instead of a number I get a letter, or a symbol, or 2 decimals.

I am making a change maker program in java.

Everything works good, the only thing i am confused about is checking the string to see if is invalid for my use, I did this for when is left empty;

         if (s1.isEmpty()) {
             JOptionPane.showMessageDialog(null, "Invalid input! ");
             System.exit(0);
         } 

That works perfect, now how can I do the else to check for letters or dots or symbols, anything that is not a number?

Aucun commentaire:

Enregistrer un commentaire