第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

用重寫(xiě)equals()方法比較兩個(gè)手機(jī),屬性都相同,運(yùn)行結(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("兩個(gè)對(duì)象是相同的");

}

else{

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

}

}


}







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 回答

問(wèn)題在給第二個(gè)tele1你寫(xiě)成了tele

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

夏天吹過(guò)的風(fēng)

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

天涯CCY 提問(wèn)者

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

舉報(bào)

0/150
提交
取消

用重寫(xiě)equals()方法比較兩個(gè)手機(jī),屬性都相同,運(yùn)行結(jié)果怎么是不同的

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

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

幫助反饋 APP下載

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

公眾號(hào)

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