比如: "abc".equals(str) "abc" 是字面量常量,永远不会是 null。 不管 str 是不是 null,程序都不会抛空指针异常,安全! str.equals("abc") 如果 str == null,程序直接崩掉,抛出 NullPointerException!