- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to check if a string is empty or not
The following is our string −
String str = "";
We will check whether it is empty or not using the isEmpty() method. The result will be a boolean −
str.isEmpty()
The following is an example −
Example
public class Demo { public static void main(String[] args) { String str = ""; System.out.println("String is empty: "+str.isEmpty()); } }
Output
String is empty: true
Advertisements