Monday 29 April 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...