write a program to validate pan number?

Here we validate a pan number that is valid or not. A PAN number is a combination character and number. It should have exactly 10 character.

  • We create a validate method with string argument type.
  • These method is Boolean return type.
  • Inside if condition we check given pan number is matches with regular expression [a-zA-Z0-9] value.
  • If pan number is small and capital letter, also numeric value then it return true else false.
  • Now print the status value.
				
					public class ValidatePanNumber {
	public static boolean validate(String panNumber) {
		if (panNumber.matches("[a-zA-Z0-9]+")) {
			return true;
		} else {
			return false;
		}
	}

	public static void main(String[] args) {
		boolean status = validate("ACYPYu931A");
		System.out.println("status is-- " + status);
	}
}
				
			

Output :-
status is– true

write a program to validate pan number? Read More »