前言
面试
因为细节内容实在太多啦,因此只把部分知识点截图出来粗略的介绍,每一个小节点里面都有更细化的内容!算法
整理了一份Java核心知识点。覆盖了JVM、锁、并发、Java反射、Spring原理、微服务、Zookeeper、数据库、数据结构等大量知识点。数据库
若是须要获取到这个【资料】文档的话 扫一扫下面数组
if (isPrototypeCurrentlyInCreation(beanName)) { throw new BeanCurrentlyInCreationException(beanName);}复制代码
public class A { private B b;}// 类B:public class B { private A a;}复制代码
/** * 放置建立好的bean Map */ private static Map<String, Object> cacheMap = new HashMap<>(2); public static void main(String[] args) { // 伪装扫描出来的对象 Class[] classes = {A.class, B.class}; // 伪装项目初始化实例化全部bean for (Class aClass : classes) { getBean(aClass); } // check System.out.println(getBean(B.class).getA() == getBean(A.class)); System.out.println(getBean(A.class).getB() == getBean(B.class)); } @SneakyThrows private static <T> T getBean(Class<T> beanClass) { // 本文用类名小写 简单代替bean的命名规则 String beanName = beanClass.getSimpleName().toLowerCase(); // 若是已是一个bean,则直接返回 if (cacheMap.containsKey(beanName)) { return (T) cacheMap.get(beanName); } // 将对象自己实例化 Object object = beanClass.getDeclaredConstructor().newInstance(); // 放入缓存 cacheMap.put(beanName, object); // 把全部字段当成须要注入的bean,建立并注入到当前bean中 Field[] fields = object.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true); // 获取须要注入字段的class Class<?> fieldClass = field.getType(); String fieldBeanName = fieldClass.getSimpleName().toLowerCase(); // 若是须要注入的bean,已经在缓存Map中,那么把缓存Map中的值注入到该field便可 // 若是缓存没有 继续建立 field.set(object, cacheMap.containsKey(fieldBeanName) ? cacheMap.get(fieldBeanName) : getBean(fieldClass)); } // 属性填充完成,返回 return (T) object; }复制代码
class Solution { public int[] twoSum(int[] nums, int target) { Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { int complement = target - nums[i]; if (map.containsKey(complement)) { return new int[] { map.get(complement), i }; } map.put(nums[i], i); } throw new IllegalArgumentException("No two sum solution"); }}复制代码
因为细节内容实在太多啦,因此只把部分知识点截图出来粗略的介绍,每一个小节点里面都有更细化的内容!缓存
整理了一份Java核心知识点。覆盖了JVM、锁、并发、Java反射、Spring原理、微服务、Zookeeper、数据库、数据结构等大量知识点。bash
若是须要获取到这个【资料】文档的话 扫一扫下面数据结构