Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Check the Empty String in Java
WhatsApp
Alagunila Meganathan
Aug 02
2016
635
0
0
check-empty-string-e
import
org.apache.commons.lang.StringUtils;
public
class
CheckEmptyStringExample
{
public
static
void
main(String[] args)
{
String string1 =
""
;
String string2 =
"\t\r\n"
;
String string3 =
" "
;
String string4 =
null
;
String string5 =
"Hi"
;
System.out.println(
"\nString one is empty? "
+
StringUtils.isBlank(string1));
System.out.println(
"String one is not empty? "
+
StringUtils.isNotBlank(string1));
System.out.println(
"\nString two is empty? "
+
StringUtils.isBlank(string2));
System.out.println(
"String two is not empty?"
+
StringUtils.isNotBlank(string2));
System.out.println(
"\nString three is empty?"
+
StringUtils.isBlank(string3));
System.out.println(
"String three is not empty?"
+
StringUtils.isNotBlank(string3));
System.out.println(
"\nString four is empty?"
+
StringUtils.isBlank(string4));
System.out.println(
"String four is not empty?"
+
StringUtils.isNotBlank(string4));
System.out.println(
"\nString five is empty?"
+
StringUtils.isBlank(string5));
System.out.println(
"String five is not empty?"
+
StringUtils.isNotBlank(string5));
}
}
Java
Up Next
Check the Empty String in Java