源码学习(待续)
来源:互联网 发布:泰国和中国的关系 知乎 编辑:程序博客网 时间:2024/05/16 18:03
System.out.println("----------start------------"); System.out.println("----------LIST(Start)------------"); /** * ArrayList实质是Object[] * LinkedList */ List<Integer> arrayList = new ArrayList<>(); List<Integer> linkList = new LinkedList<>(); //List<Integer> arrayListTmp = new ArrayList<>(); //System.out.println(arrayList == arrayListTmp); //System.out.println(arrayList.hashCode() + "-" + arrayListTmp.hashCode()); System.out.println("----------LIST(End)------------"); System.out.println("----------SET(Start)------------"); /** * HashSet(){ * new HashMap<>(); * } * LinkedHashSet extends HashSet * 有序体现在迭代器 */ Set<String> hashSet = new HashSet<>(); Set<String> linkedHashSet = new LinkedHashSet<>(); for(int i = 0;i<30;i++) { hashSet.add(i+""); linkedHashSet.add(i+""); } Iterator<String> iterator = hashSet.iterator(); while(iterator.hasNext()){ System.out.print(iterator.next() + " "); } System.out.println(""); iterator = linkedHashSet.iterator(); while(iterator.hasNext()){ System.out.print(iterator.next() + " "); } System.out.println(""); System.out.println("----------SET(End)------------"); /** *static class Node<K,V> implements Map.Entry<K,V> { * final int hash; * final K key; * V value; * Node<K,V> next; * * Node(int hash, K key, V value, Node<K,V> next) { * this.hash = hash; * this.key = key; * this.value = value; * this.next = next; * } * * public final K getKey() { return key; } * public final V getValue() { return value; } * public final String toString() { return key + "=" + value; } * * public final int hashCode() { * return Objects.hashCode(key) ^ Objects.hashCode(value); * } * * public final V setValue(V newValue) { * V oldValue = value; * value = newValue; * return oldValue; * } * * public final boolean equals(Object o) { * if (o == this) * return true; * if (o instanceof Map.Entry) { * Map.Entry<?,?> e = (Map.Entry<?,?>)o; * if (Objects.equals(key, e.getKey()) && * Objects.equals(value, e.getValue())) * return true; * } * return false; * } *} */ Map<String,String> hashMap = new HashMap<>(10); for(int i = 0; i< 100 ;i++){ hashMap.put("key"+i,"value"+i); }// 一切对象皆有HashCode// Integer i = 1;// i.hashCode();// hashMap.hashCode();// String str1 = new String("key");// String str = new String("key");// str.indexOf("k");// System.out.println(str1 == str);// System.out.println(str1.hashCode() + "-" + str.hashCode()); Map<String,String> linkedHashMap = new LinkedHashMap<>();
阅读全文
0 0
- 源码学习(待续)
- Github Webbench 源码分析+学习(待续)
- 深度学习(八)caffe源码学习-未完待续
- 深度学习(八)caffe源码学习-未完待续
- Libpcap学习(待续)
- Java集合源码学习(2):ArrayList和LinkedArrayList(未完待续...)
- GDI+学习笔记(待续)
- SQL学习笔记(待续)
- java学习总结(待续)
- 排序学习总结(待续)
- vim学习笔记(待续...)
- 学习小感(待续...)
- EJB学习笔记 (待续)
- drupal学习教程(待续)
- 机器学习(未完待续)
- 几道面试题,附源码(待续)
- 阅读EventBus源码(笔记)待续
- ros::init源码分析(未完待续。)
- Spring Boot 入门
- QT 程序完全打开前的开启画面
- 关于 Bootstrap validator remote 的delay 属性 没效果
- 优化加号+操作符
- just4fun:神奇的代码生成好看的图片
- 源码学习(待续)
- Tesseract-OCR学习系列(二)构建
- 琐碎c++1
- linux的触摸屏:手工调试 && 调试各种TP时碰到的问题
- 第十章 会话管理
- tomcat挂掉后自动重启脚本
- 如何平衡页面和页面优化
- 建造者模式(Builder)
- linux ls命令学习