判断值是否相等不要用“==”
public static void main(String[] args) {
String abc = "Hello, World!";
System.out.println(abc.substring(0, 1) == "H"); // false
System.out.println(abc.substring(0, 1).equals("H")); // true
}
:::tips Tips:”==” 只能够确定两个字符串是否放置在同一个位置上。 :::