下午到了百度大厦感受这一辈子有幸再一次来到这里真心高兴。梦开始的地方不能忘。不忘初心方的始终。 第一面 基础知识面试 首先问了hashmap是如何存储数据、找数据的。java
第一点,单个数据是什么结构面试
jdk1.6spring
transient Entry[] table;
hashmap容许key值为空放置微信
public V put(K key, V value) { if (key == null) return putForNullKey(value); int hash = hash(key.hashCode()); int i = indexFor(hash, table.length); for (Entry<K,V> e = table[i]; e != null; e = e.next) { Object k; if (e.hash == hash && ((k = e.key) == key || key.equals(k))) { V oldValue = e.value; e.value = value; e.recordAccess(this); return oldValue; } } modCount++; addEntry(hash, key, value, i); return null; }
这里要注意了,判断相等是首先判断hash值是否相等,若是相等还要判断key值是否相等(有== 和equal两种状况)。this
jdk1.8code
transient Node<K,V>[] table;
jdk1.8hashmap的实现和1.6的差异仍是蛮大的。继承
jdk1.6的节点就是Entry链的形式。这样若是数据很大的状况下,查找要从头至尾,效率比较低。索引
jdk1.8将Entry链改为了TreeNode。TreeNode继承自LinkedHashMap.Entry<K,V>,自己维护了一个红黑树。事务
这样在开练解决冲突的时候会将冲突数据组织成红黑树,当查找某个数据的时候查找次数不会超过logn,查找效率获得了提升。get
spring的事务传播和事务隔离。
见个人相关文章,这块表述清楚就好。
主键索引和惟一索引
主键和惟一索引都要求值惟一,可是它们仍是有区别的:
①.主键是一种约束,惟一索引是一种索引;
②.一张表只能有一个主键,但能够建立多个惟一索引;
③.主键建立后必定包含一个惟一索引,惟一索引并必定是主键;
④.主键不能为null,惟一索引能够为null;
⑤.主键能够作为外键,惟一索引不行;
模式(写个单利)
public class Singleton { private volatile static Singleton singleton; private Singleton (){} public static Singleton getSingleton() { if (singleton == null) { synchronized (Singleton.class) { if (singleton == null) { singleton = new Singleton(); } } } return singleton; } }
第二面 项目方面、代码能力
所作的项目,如何能适应修改,代码的可扩展性如何理解
第三方面 我的素养、职位匹配度
加班如何看待、作过什么东西有深度和广度的提高。
对百度口号“简单,可依赖”怎么理解。
加微信:hyssop的后花园 (技术公众号)