select student.id,student.name,book.stu_id ,count(*) as total from student, book where
student.id=book.stu_id and student.age=18 and student.gender=‘男’
group by book.name
order by total desc limit 1;
面试时没看到book中id是否为主键的问题,如果为主键那么久不能有重复值,假设book的name是没有重复的,所以按照book的名称分组,然后计算每组的数目,降序排列取第一个。正产应该有个borrow_id,为主键,然后按照book_id分组。
HashMap的底层实现原理:
底层数据结构:数组+链表+红黑树(jdk1.8后)
HashMap可以接受null键值和值,线程不安全,HashMap使用链表来解决碰撞问题,当发生碰撞了,对象将会储存在链表的下一个节点中。
HashMap是基于hashing的原理,我们使用put(key,value)存储对象到HashMap中,使用get(key)从HashMap中获取对象。当我们给put()方法传递键和值时,