重写equals方法后执行结果不对
che和NSX的color,我都赋值为白色啊,结果应该为same啊。代码如下:
package com.benz;
public class IntialinCar {
public static void main(String[] args) {
Car che = new Car();
che.color = "baise";
// che.engine = 4;
// che.speed = 100;
Honda NSX = new Honda();
NSX.color = "baise";
// NSX.engine = 4;
// NSX.speed = 100;
NSX.run();
//NSX.cheJiaHao(4);
Honda bentian = new Honda();
//bentian.cv();
System.out.println(bentian);
NSX.color = "baise";
bentian.color = "c";
if(che.equals(NSX)){
System.out.println("same");
}else{
System.out.println("no.");
}
}
}