Q:

How do you test that a string is the empty string

How do you test that a string str is the empty string? 
Below is the code I tried, but when I just hit enter on eclipse console, it does not print right output which should be "String is Null"
public static void main(String[] args) {
    Scanner in=new Scanner(System.in);
    out.print("Press Y to continue: ");
    String yes= in.next();
    int LengthOfInput = yes.length();
    if (LengthOfInput==0)
    {
        out.print("String is Null");
    }
    else {
        out.print("String not null");
    }
}

}

A:

Your method correctly identifies whether a string is empty. Other than this method, you can also call isEmpty on a string or check of the string is equal to ""
if (string.isEmpty())

if (string.equals(""))

The reason why your code did not work as expected is because you read the user input wrongly. next method by default will not return an empty string because it will always try to find something to read.
To achieve your intended behaviour call nextLine instead of next.

