package errorhandling;
import java.util.Scanner;
public class ErrorHandling {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter name:\n");
String name = scan.nextLine();
char[] str = name.toCharArray();
StringBuilder builder = new StringBuilder();
for(char c : str){
if(Character.isDigit(c)){
System.out.println("No digits allowed in the given field");
builder.append(c);
}
}
}
}
Comments
Leave a comment