java 常见bug
2022-03-22 本文已影响0人
暴躁程序员
- 两个字符串比较,必须使用equals()方法,而不能用 ==
String strA = "hello world";
String strB = "Hello world".toLowerCase();
System.out.println(strA == strB);
System.out.println(strA.equals(strB));
String strA = "hello world";
String strB = "Hello world".toLowerCase();
System.out.println(strA == strB);
System.out.println(strA.equals(strB));