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
On this page of the site you can watch the video online How to check whether a String is empty or not using the Java isEmpty() method with a duration of hours minute second in good quality, which was uploaded by the user Career & Tech HQ 09 June 2020, share the link with friends and acquaintances, this video has already been watched 768 times on youtube and it was liked by 7 viewers. Enjoy your viewing!