Given a string str, the task is to check if this string is empty or not, in Java.
Input: str = "" Output: True Input: str = "GFG" Output: False
- Get the String to be checked in str
- We can simply check if the string is empty or not using the isEmpty() method of String class
- Print true if the above condition is true. Else print false.
Below is the implementation of the above approach:
Is string "GeeksforGeeks" empty? false Is string "" empty? true
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Check if a string can become empty by recursively deleting a given sub-string
- String slicing in Python to check if a string can become empty by recursive deletion
- Minimum number of palindromic subsequences to be removed to empty a binary string
- Operations required to make the string empty
- Count of non-empty sequences of a String
- Sum of indices of Characters removed to obtain an Empty String based on given conditions
- Minimize cost to empty a given string by removing characters alphabetically
- Count of ways to split given string into two non-empty palindromes
- IntStream empty() in Java with examples
- DoubleStream empty() in Java with examples
- LongStream empty() in Java with examples
- Stream empty() in Java with Examples
- Stack empty() Method in Java
- OptionalLong empty() method in Java with examples
- OptionalDouble empty() method in Java with examples
- OptionalInt empty() method in Java with examples
- Optional empty() method in Java with examples
- Java program to check whether a string is a Palindrome
- Program to check if the String is Null in Java
- Program to check if a String in Java contains only whitespaces
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.