{"id":1917,"date":"2022-09-12T19:33:22","date_gmt":"2022-09-12T19:33:22","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=1917"},"modified":"2022-09-12T19:33:23","modified_gmt":"2022-09-12T19:33:23","slug":"java-string-isempty","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/java-string-isempty\/","title":{"rendered":"Java String isEmpty"},"content":{"rendered":"<p style=\"text-align: center;\"><strong>Java string isEmpty<\/strong><\/p>\n\n\n<p>Well, read the method. It says is empty. It is asking that \u2013 hey, is the given string empty? But first, let&#8217;s understand what we mean by an empty string. Well, this is simple. An empty string means an empty string, which means the string which is empty! Or we can say that the string does not even contain space. Or in even other words, we can say that the string has a length of zero.<\/p>\n\n\n\n<p>We have seen somewhere earlier how can we create an empty string. Well, still if you are confused about how to create an empty string, we are going to do a program for the same thing.<\/p>\n\n\n\n<p>Have a look at the program &#8211;<\/p>\n\n\n\n<p class=\"has-background-color has-foreground-background-color has-text-color has-background\">public class StringMethods {<br>public static void main(String[] args) {<br>String str1 = &#8220;&#8221;;<br>\/\/ String str1 = new String(); \u2192 this is another way to create an empty string.<br>System.out.println(str1.isEmpty());<br>}<br>}<\/p>\n\n\n\n<p>So, here we can see that the string is empty. The method is also asking that is the string empty? It just returns true or false. In this case, we are getting true as an output, since the string is empty.<\/p>\n\n\n\n<p>Have a look at another program, in which, the string is not empty this time &#8211;<\/p>\n\n\n\n<p class=\"has-background-color has-foreground-background-color has-text-color has-background\">public class StringMethods {<br>public static void main(String[] args) {<br>String str1 = &#8220;Not an empty string&#8221;;<br>\/\/ String str1 = new String(); \u2192 this is another way to create an empty string.<br>System.out.println(str1.isEmpty());<br>}<br>}<\/p>\n\n\n\n<p>This time, the output is going to be clearly false, since the string is not empty. You can see that another way of creating the empty string is mentioned in both programs. You can use either of the ways to create an empty string.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java string isEmpty Well, read the method. It says is empty. It is asking that \u2013 hey, is the given string empty? But first, let&#8217;s understand what we mean by an empty string. Well, this is simple. An empty string means an empty string, which means the string which is empty! Or we can say [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[12,11],"class_list":{"0":"post-1917","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-java-tutorial","7":"tag-java","8":"tag-java-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=1917"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1917\/revisions"}],"predecessor-version":[{"id":3004,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1917\/revisions\/3004"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=1917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=1917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=1917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}