Java judges whether the string is null, and java judges the string
The following are three methods for Java to determine whether a string is null.
Method 1: The method that most people use is intuitive, convenient, but inefficient.
Method 2: Compare the string length with high efficiency. It is the best method I know.
Method 3: the method provided by Java SE 6.0 is almost the same as method 2. For compatibility reasons, method 2 is recommended.
1: if (s = null | s. equals (""); 2: if (s = null | s. length () <= 0); 3: if (s = null | s. isEmpty ());
Java checks whether the string is null.
The following are three methods for Java to determine whether a string is null.
Method 1: The method that most people use is intuitive, convenient, but inefficient.
1: if (s = null | s. equals (""));
Method 2: Compare the string length with high efficiency. It is the best method I know.
2: if (s = null | s. length () <= 0 );
Method 3: the method provided by Java SE 6.0 is almost the same as method 2. However, for compatibility considerations, we recommend that you use this method.
3: if (s = null | s. isEmpty ());
Java checks whether the string is null.
The following are three methods for Java to determine whether a string is null.
Method 1: The method that most people use is intuitive, convenient, but inefficient.
1: if (s = null | s. equals (""));
Method 2: Compare the string length with high efficiency. It is the best method I know.
2: if (s = null | s. length () <= 0 );
Method 3: the method provided by Java SE 6.0 is almost the same as method 2. However, for compatibility considerations, we recommend that you use this method.
3: if (s = null | s. isEmpty ());