How to test whether the entered value is numeric or it contains some characters.
here is the code which i have written
Code:
import java.util.Scanner;
public class Assignment {
public static void main(String[] args) {
int row, column;
int s=0;
boolean found = false;
String rollNumber;
while (!found) {
try {
Scanner scan = new Scanner(System.in);
System.out.print("Enter the size of the array s: ");
String size = scan.next();
System.out.println("size is :" +size);
System.out.println();
found = true;
} catch (NumberFormatException nfe) {
System.out.print("Please enter the number again in correct format:");
System.out.println();
}
}
// int[][] arr = new int[size][3];
}
}