Given string (Input string) and we have to whether it is empty string or not?
/*Java Program to check whether string is empty or not*/
public class JavaisEmptyPrg
{
public static void main(String args[])
{
String str1="www.includehelp.com";
String str2="";
if(str1.isEmpty()==true)
System.out.println("Str1 is an empty string.");
else
System.out.println("Str1 is not an empty string.");
if(str2.isEmpty()==true)
System.out.println("Str2 is an empty string.");
else
System.out.println("Str2 is not an empty string.");
}
}
Output
Complie: javac JavaisEmptyPrg.java
Run: java JavaisEmptyPrg
Output
Str1 is not an empty string.
Str2 is an empty string.
Consider the program:
Given string (Input string) and we have to whether it is empty string or not?
Output
need an explanation for this answer? contact us directly to get an explanation for this answer