java programming
I am trying to get an applet to recognize if the input is a legal integer. I got it so that it will go to the program and do what it is supposed to do but it won't give a message if it is not a number. This is my code:
public void test() throws NumberFormatException { if (testNumberField.getText() != null) { PrimeTest(); } else { answer.setText("this is not a number!"); } } what am I doing wrong? mAineAc |
Hello mAineAc.
Firstly I'm probably newer to java than you but a few things ocurred to me when I saw this. Here's some things to try: Isn't an exception best dealt with using something like: Code:
try { This might have helped sorry if it hasn't. |
thank you that is just what i was looking for. I am pretty new to java.
mAineAc |
BTW, I just peeked at my CD reference (Java Power Reference from O'Reilly - highly recommended) and it does offer the following:
Code:
public static boolean java.lang.Double.isNaN(double v); Glad to be of help, mAineAc. |
All times are GMT -5. The time now is 05:00 AM. |