Testing for String Equality
if (name.compareTo(“Jerry”) == 0) …if (name == “Jerry”) …if (name.equals(“Jerry”)) …if (“”.equals(name)) … All the above comparisons are correct, but they are not great. The compareTo method is overkill and
if (name.compareTo(“Jerry”) == 0) …if (name == “Jerry”) …if (name.equals(“Jerry”)) …if (“”.equals(name)) … All the above comparisons are correct, but they are not great. The compareTo method is overkill and