How can I print error messages from my function when the integer are invalid? If I type string or character, Show "TYPE NUMBER ONLY"
import java.util.*;
public class CheckNumberOnly {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a,i;
Scanner obj=new Scanner(System.in);
System.out.println("TYPE A");
a=obj.nextInt();
i=a;
if(i==a){
System.out.println("A is "+i);
}
else{
System.out.println("TYPE NUMBER ONLY");
}
}
}