Java test String is null or empty


Java test String is null or empty

import java.lang.*;

public class StringDemo {

   public static void main(String[] args) {

      String str = "codingdict";

      // prints length of string

      System.out.println("length of string = " + str.length());



      // checks if the string is empty or not

      System.out.println("is this string empty? = " + str.isEmpty());

   }

}