public class Employee {
String name;
public Employee(String var){ this.name=var;}
}
public class Main {
public static void main(String[] args){
String s1=new String("joe");
String s2=new String("joe");
Employee e1=new Employee("joe");
Employee e2=new Employee("joe");
system.out.println("When comparing String obj:"+s1.equals(s2)); output:TRUE
system.out.println("When comparing Employee obj:+e1.equals(e2)): output:FALSE
に等しいです。また助けが必要です!は対文字列のために等しい私たちは、Employeeクラスを上書きする必要があります知っているが、なぜそれがStringクラスのために働いていると私はStringクラスは、Oracleのドキュメントにメソッドをオーバーライド等号を見つけることができませんでし員/ OTHRクラスの
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#equals(java.lang.Object)? – zerkms
別のオブジェクトを宣言すると、条件に一致しません。また、2番目のオブジェクトをEmployee e2 = e1と宣言する場合はfalseを返します。それは真実を返す – Vickyexpert