最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機立即綁定

用重寫equals()方法比較兩個手機,屬性都相同,運行結(jié)果怎么是不同的

package com.imooc;


public class infial {


public static void main(String[] args) {

// TODO Auto-generated method stub

Telephone tele=new Telephone();

tele.size=10;

tele.CPU=10;

tele.Memory=10;

Telephone tele1=new Telephone();

tele.size=10;

tele.CPU=10;

tele.Memory=10;

if(tele.equals(tele1)){

System.out.println("兩個對象是相同的");

}

else{

System.out.println("兩個對象是不相同的");

}

}


}







package com.imooc;


public class Telephone {

? ? ? ? ?int size;

? ? ? ? ?int CPU;

? ? ? ? ?int Memory;

@Override

public boolean equals(Object obj) {

if (this == obj)

return true;

if (obj == null)

return false;

if (getClass() != obj.getClass())

return false;

Telephone other = (Telephone) obj;

if (CPU != other.CPU)

return false;

if (Memory != other.Memory)

return false;

if (size != other.size)

return false;

return true;

}

? ? ? ? ?

}


正在回答

1 回答

問題在給第二個tele1你寫成了tele

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

夏天吹過的風(fēng)

在賦值的時候
2018-03-04 回復(fù) 有任何疑惑可以回復(fù)我~
#2

天涯CCY 提問者

非常感謝!
2018-03-04 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

用重寫equals()方法比較兩個手機,屬性都相同,運行結(jié)果怎么是不同的

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號