Monday, April 29, 2019

java - Check if a specific string contains any lower/uppercase

Solution :



String name1="test";


System.out.println(name1.toLowerCase().equals(name1)); //true
System.out.println(name1.toUpperCase().equals(name1)); //false


The logic is
if the first statement is true it means the string has only lower case letters.
if the second statement is true it means the string has only upper case letters.
if both are false it means that it has a mixture of both.

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...