Checking for string contents? string Length Vs Empty String

前端 未结 13 949
野趣味
野趣味 2020-12-17 10:14

Which is more efficient for the compiler and the best practice for checking whether a string is blank?

  1. Checking whether the length of the string == 0
13条回答
  •  忘掉有多难
    2020-12-17 10:38

    In Java 1.6, the String class has a new method [isEmpty] 1

    There is also the Jakarta commons library, which has the [isBlank] 2 method. Blank is defined as a string that contains only whitespace.

提交回复
热议问题