【重点,要考的】数据结构及算法基础--哈希图(HashMap)
HashMap可以说是java中最常见的几种集合了。 在了解HashMap前我们要先了解Object的两个方法:Equals和hashCode() 首先我们来看一下object内的源码是怎样实现的: hashcode(): /** * Returns a hash code value for the object. This method is * supported for the benefit of hash tables such as those provided by * {@link java.util.HashMap}. * <p> * The general contract of {@code hashCode} is: * <ul> * <li>Whenever it is invoked on the same object more than once during * an execution of a Java application, the {@code hashCode} method * must consistently return the same integer, provided no information * used in {@code equals} comparisons on the object is modified