If I understand you correctly, you are reading an integer or string from standard input as strings, and you want to validate that the integer is actually an integer. Perhaps the trouble you are having is that Integer.parseInt() which can be used to convert a String to an integer throws NumberFormatException. It sounds like your assignment has forbidden the use of exception-handling (did I understand this correctly), and so you are not permitted to use this builtin function and must implement it yourself.
Ok. So, since this is homework, I am not going to give you the complete answer, but here is the pseudocode:
let result = 0 // accumulator for our result
let radix = 10 // base 10 number
let isneg = false // not negative as far as we are aware
strip leading/trailing whitespace for the input string
if the input begins with '+':
remove the '+'
otherwise, if the input begins with '-':
remove the '-'
set isneg to true
for each character in the input string:
if the character is not a digit:
indicate failure
otherwise:
multiply result by the radix
add the character, converted to a digit, to the result
if isneg:
negate the result
report the result
The key thing here is that each digit is radix times more significant than the digit directly to its right, and so if we always multiply by the radix as we scan the string left to right, then each digit is given its proper significance. Now, if I'm mistaken, and you actually can use try-catch but simply haven't figured out how:
int result = 0;
boolean done = false;
while (!done){
String str = // read the input
try{
result = Integer.parseInt(str);
done = true;
}catch(NumberFormatException the_input_string_isnt_an_integer){
// ask the user to try again
}
}