Fix Null Pointer Exception in strings/Upper (#3005)

Co-authored-by: Yang Libin <contact@yanglibin.info>
This commit is contained in:
acbin 2022-04-05 17:02:20 +08:00 committed by GitHub
parent e7ff986414
commit ab544c3b9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,9 @@ public class Upper {
* @return the {@code String}, converted to uppercase.
*/
public static String toUpperCase(String s) {
if (s == null || "".equals(s)) {
return s;
}
char[] values = s.toCharArray();
for (int i = 0; i < values.length; ++i) {
if (Character.isLetter(values[i]) && Character.isLowerCase(values[i])) {