In this example you are going to learn another example on using the java.lang.Character
class. The Character.isLowerCase()
method can be used to determine if a letter is a lowercase letter. This method takes a char
as argument and return a boolean value. If it returns true
it means the character is in lowercase form. And if it returns false
it means the character is not in lowercase form.
Beside using the isLowerCase()
method you can also compare the character type with the constant value of Character.LOWERCASE_LETTER
. To get the character type you can use the Character.getType()
method. You can see the example on the following code snippet.
package org.kodejava.lang;
public class CharacterIsLowerCaseExample {
public static void main(String[] args) {
char a = 'a';
// Checks to see if a letter is a lowercase letter.
if (Character.isLowerCase(a)) {
System.out.println(a + " is a lowercase letter.");
}
// Checks to see if a letter is a lowercase letter
// by comparing the character type against
// Character.LOWERCASE_LETTER constant value.
int charType = Character.getType(a);
if (charType == Character.LOWERCASE_LETTER) {
System.out.println(a + " is a lowercase letter.");
}
}
}
This example give you the following output:
a is a lowercase letter.
a is a lowercase letter.
Latest posts by Wayan (see all)
- How do I create a table with multiple header in iText 8? - March 16, 2024
- How do I add Image to a Table in iText 8? - March 11, 2024
- How do I downgrade Android SDK emulator version? - February 12, 2024