Answer to Question #255132 in Java | JSP | JSF for Special ops 1

Question #255132
Write a general error handling class that has general functions that would take in a string, which the main pages would get as an input and those functions can search for specific things. For example: any sort of input from the user where we would expect them to make a mistake( like where they enter numbers into their name in user login).
1
Expert's answer
2021-10-22T07:39:49-0400


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);
         }
      }
      
    }
    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS