Hi Java Professionals,
I need to allow users only enter integer into a String variable, "input" and I am not sure what statement to use. Please help, thanks a lot in advance.
import java.util.Scanner;
public class assq2b
{
public static void main(String []args)
{
Scanner reader = new Scanner(System.in);
String input,b;
long checked;
System.out.print("Please enter the 12 digit:");
input = reader.nextLine();
if((input.length() < 12) || (input.length() > 12))
{
System.out.println("The entered digits is not equal to 12.");
System.exit(0);
}
else
{
System.out.println("Calculating...");
}
checked =Long.parseLong(input);