Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

java
communitycreator

What is StringUtils.isAllLowerCase in Java?

abhilash

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

isAllLowerCase is a static method of the StringUtils class that checks whether all the characters in a given string are lowercase or not.

You can use Character.isLowerCase to determine if a character is lowercase or not.

How to import StringUtils

StringUtils is defined in the Apache Commons Lang package. Add Apache Commons Lang to the Maven project by adding the following dependency to the pom.xml file.

<dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
</dependency>

Note: For other versions of the commons-lang package, refer to the Maven Repository.

You can import the StringUtils class as follows:

import org.apache.commons.lang3.StringUtils;

Syntax


public static boolean isAllLowerCase(final CharSequence cs)

Parameters

  • CharSequence cs: The character sequence to check.

Return value

The function returns true if all the characters in the character sequence are lowercase. Otherwise, it returns false.

Code

import org.apache.commons.lang3.StringUtils;
public class Main{
public static void main(String[] args){
String characterSequence = "educative";
System.out.println(StringUtils.isAllLowerCase(characterSequence));
characterSequence = "educAtive";
System.out.println(StringUtils.isAllLowerCase(characterSequence));
}
}

Explanation

  1. string = "educative".

    The function returns true since all the characters in the string are lowercase.

  2. string = "educAtive".

    The function returns false since the character A is uppercase.

Output

The output of the code will be as follows:


true
false

RELATED TAGS

java
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring