How to check whether a String is empty or not using the Java isEmpty() method

Publié le: 09 juin 2020
sur la chaîne: Career & Tech HQ
768
7

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


Sur cette page du site, vous pouvez voir la vidéo en ligne How to check whether a String is empty or not using the Java isEmpty() method durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Career & Tech HQ 09 juin 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 768 fois et il a aimé 7 téléspectateurs. Bon visionnage!