Java String Handling

Check if String is lowercase in Java example

This Java example shows how to check if String is lowercase in Java. Example also shows how to check if String is lowercase using various approaches.

How to check if String is lowercase in Java?

We want to check if String is lowercase. This can be done in below given approaches.

1) Check if String is lowercase using char array and Character class

We can check if String is lowercase using character array and isLowerCase method of Character class as given below.


What about the input string “james bond, 007”. Well, our program will output false for this input value. That is because string contains numbers, spaces and a comma for which isLowerCase method returns false. To fix that, before checking if the character is lowercase, we need to first check if it is letter as given below.


You can also use isUpperCase method instead of isLowerCase to address the non-letter character problem as given below.

2) Check if String is lowercase using toLowerCase and equals methods

We can convert the string to lowercase and compare it with the original string. If they are equal then the string is in lowercase as given below.


3) Check if String is lowercase using Apache Commons library

If you are using Apache Commons library, you can use isAllLowerCase method of StringUtils class to check if the String is lowercase as given below.


Note: If string contains any non-letter characters including space, isAllLowerCase method returns false.

Please let us know your views in the comments section below.


About the author



rahimv has over 15 years of experience in designing and developing Java applications. His areas of expertise are J2EE and eCommerce. If you like the website, follow him on Facebook, Twitter or Google Plus.

Add Comment

Your email address will not be published. Required fields are marked *