How to check whether a String is empty or not using the Java isEmpty() method
Coding River
How to check whether a String is empty or not using the Java isEmpty() method
In this video, we will talk about the Java isEmpty() method, which is used to check whether a String is empty or not. This method returns a Boolean value. True if the given String is empty that is to say if the length of the String is 0. And it returns false if the given String is not empty. Let’s take an example to see how this method works
String str1 = “ ”; String str2 = “”;
System.out.println(str1.isEmpty()); This will program will return false, because as you know, the white space is considered as a character. So, str1 is not empty.
System.out.println(str2.isEmpty()); This statement will return true, str2 is indeed empty
#codingriver #java #programming ... https://www.youtube.com/watch?v=J7ozSzUAgLs
5779182 Bytes