I am trying to write a program, but my client might not type in the information in the correct format. How do I tell if a String is an int in Java (so I can throw an error message that I write and allows them to retry)? I.e., is there a method in java that will allow me to check if String str is of type int?
String input=kb.nextLine();
if(input.(isInteger method)&&(int)input==otherint)
do stuff inside here;
else
do different stuff;
An answer should include the imports needed (if any) and basic method. Also, as simple as possible would be very good. If this is actually a copy of a question, post the link (I looked for a while but couldn't find anything on google or here that seemed like it would solve my problem).