Calling String.isEmpty() clearly communicates the code’s intention, which is to test if the string is empty. Using
String.length() == 0 is less direct and makes the code less readable.
if ("string".length() == 0) { /* … */ } // Noncompliant
if ("string".length() > 0) { /* … */ } // Noncompliant
if ("string".isEmpty()){ /* … */ }
if (!"string".isEmpty()){ /* … */ }