Java String.equals 与 ==
String.equals() 比较内容,而 == 检查引用是否指向同一对象。
示例
请参见以下示例图解 −
public class Tester {
public static void main(String[] args) {
String test = new String("a");
String test1 = new String("a");
System.out.println(test == test1);
System.out.println(test.equals(test1));
}
}输出
false true
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言
C++
C#
MongoDB
MySQL
Javascript
PHP