如何在StringBuilder上检查空值?
2022-09-02 05:29:30
我想在我的代码中专门检查空或空。在 Java 中,空和空值是否相同?StringBuilder
例如:
StringBuilder state = new StringBuilder();
StringBuilder err= new StringBuilder();
success = executeCommand(cmd, state, err);
/* here executeCommand() returns empty or null in state, I cant make changes in <br/> executeCommand() so can I check it in my code somehow for state, if its null or empty? */<br/>
if (state == null) { //do blabla1 }
if (state.tostring().equals("")) { //do blabla2 }
上面的代码有意义吗,或者我应该如何更改它?