![]() |
Given a string str, the task is to check if this string is empty or not, in Java. Examples: Input: str = "" Output: True Input: str = "GFG" Output: False Approach 1:
if (str.isEmpty())
Below is the implementation of the above approach: Java
Output:
Is string "GeeksforGeeks" empty? false Is string "" empty? true Approach 2: Using length() method If the length of the string is zero then the string is empty. Java
Output
Is string "GeeksforGeeks" empty? false Is string "" empty? true |
Reffered: https://www.geeksforgeeks.org
DSA |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 10 |