try{
name= JOptionPane.showInputDialog("Enter Employee Name: ");
}
<br />
catch (Exception e){
//wHAT IS THE CODE HERE if THE INPUT IS NUMERIC
JOptionPane.showInputDialog("Invalid Input");
}
lloydsbackyard
0
Light Poster
Recommended Answers
Jump to PostWell here is one solution:
public class IsItAnInt { public static boolean isInt(String number){ try{ int a = Integer.parseInt(number); return true; } catch(Exception evt){ return false; } } public static void main(String[] args){ System.out.println("is 12 an int? : " + isInt("12")); System.out.println("is 1234fd an int?: " + …
Jump to PostI just gave you the method, just use isInt() method. Take out the try and catch and use an if/else statement.
All 5 Replies
godzab
0
Junior Poster in Training
lloydsbackyard
0
Light Poster
lloydsbackyard
0
Light Poster
godzab
0
Junior Poster in Training
lloydsbackyard
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.