Write the code to test isLowerCase(int codePoint) method
In this step, we'll write the code to test the isLowerCase(int codePoint)
method.
import java.util.Scanner;
public class IsLowerCaseDemo{
public static void main(String[] args){
//Test 1: calling isLowerCase(int codePoint) for a lowercase character
int cp1 = 97;
boolean b1 = Character.isLowerCase(cp1);
System.out.println((char)cp1 +" is a lowercase??: "+b1);
//Test 2: calling isLowerCase(int codePoint) for an uppercase character
int cp2 = 65;
boolean b2 = Character.isLowerCase(cp2);
System.out.println((char)cp2 +" is a lowercase??: "+b2);
//Test 3: calling isLowerCase(int codePoint) for a numeric character
int cp3 = 49;
boolean b3 = Character.isLowerCase(cp3);
System.out.println((char)cp3 +" is a lowercase??: "+b3);
//Test 4: calling isLowerCase(int codePoint) for a special character
int cp4 = 42;
boolean b4 = Character.isLowerCase(cp4);
System.out.println((char)cp4 +" is a lowercase??: "+b4);
//User input test: calling isLowerCase(int codePoint) for user input characters
try{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a Unicode character: ");
int cp5 = sc.nextInt();
boolean b5 = Character.isLowerCase(cp5);
System.out.println((char)cp5 + " is a lowercase?: "+b5);
} catch(Exception e){
System.out.println("Invalid input!");
}
}
}