isAllUpperCase
is a static method of the StringUtils
class that checks whether all the characters in a given string are uppercase or not.
You can use Character.isUpperCase to determine if a character is uppercase or not.
StringUtils
StringUtils
is defined in the Apache Commons Lang package. Apache Commons Lang can be added 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;
public static boolean isAllUpperCase(final CharSequence cs)
CharSequence cs
: The character sequence to check.The function returns true
if all the characters in the character sequence are uppercase. Otherwise, it returns false
.
import org.apache.commons.lang3.StringUtils;public class Main{public static void main(String[] args){String characterSequence = "EDUCATIVE";System.out.println(StringUtils.isAllUpperCase(characterSequence));characterSequence = "EdUCATIVE";System.out.println(StringUtils.isAllUpperCase(characterSequence));}}
The output of the code will be as follows:
true
false
"EDUCATIVE"
.The function returns true
since all the characters in the string are uppercase.
"EdUCATIVE"
.The function returns false
since the character d
is lowercase.