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