`
lihengzkj
  • 浏览: 44231 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论
文章列表
set的实现类HashSet/TreeSet的底层实现是通过HashMap/TreeMap来实现的。Set的实现类在创建对象的时候都,在构造方法里面都是创建了一个Map的实现类来实现的。而Map中的元素是“键-值”对,其中“键”必须是唯一的。Set就是利用“键”唯一这个特性来实现元素不重复的。它把Set中的元素作为Map的键,从而保持了元素的唯一性。 public class TestTreeSet { public static void main(String [] args){ Set set = new TreeSet(); set.add(new Element1(&q ...
克隆的主对象:(重写了clone方法) public class TestClonBean implements Cloneable,Serializable{ private String name; private int age; private String sex; @Override protected TestClonBean clone(){ TestClonBean bean = null; try { bean = (TestClonBean) super.clone(); } catch (CloneNotSupported ...
Global site tag (gtag.js) - Google Analytics