[問題] 想問一個 Encapsulation 封裝相關的問題
就是像這個教學 http://www.tutorialspoint.com/java/java_encapsulation.htm
寫個封裝的物件,
想說如果需要並且有必要設一個類似hashmap key唯一值,
假如 我有個Mac Address想把它設為唯一值需要怎麼做,
還是有其他觀念~
想請教各位大大!
public class EncapTest{
private String macAddress;
private String name;
public int getMacAddress(){
return macAddress;
}
public String getName(){
return name;
}
public void setMacAddress(String newAddress){
macAddress = newAddress;
}
public void setName(String newName){
name = newName;
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.224.2.249
※ 文章網址: https://www.ptt.cc/bbs/java/M.1451403685.A.117.html
→
12/30 21:11, , 1F
12/30 21:11, 1F
推
12/31 01:31, , 2F
12/31 01:31, 2F
→
12/31 01:33, , 3F
12/31 01:33, 3F
→
12/31 01:33, , 4F
12/31 01:33, 4F
→
12/31 01:34, , 5F
12/31 01:34, 5F
→
12/31 01:34, , 6F
12/31 01:34, 6F
java 近期熱門文章
PTT數位生活區 即時熱門文章