摘要:
双重检查锁定与延迟初始化 在Java多线程程序中,有时候需要采用延迟初始化来降低初始化类和创建对象的开销。双重检查锁定是常见的延迟初始化技术,但它是一个错误的用法。 非线程安全的延迟初始化对象 package 双重检查锁定与延迟初始化; //非线程安全的延迟初始化对象 public class Un 阅读全文
摘要:
冒泡排序 //冒泡排序 //时间复杂度为O(N^2),空间复杂度为O(N) public class BubbleSort { public static void bubbleSort(int[] arr) { if (arr.length == 0 || arr.length == 1) { r 阅读全文
摘要:
LeetCode Hot 100 link 198. 打家劫舍 你是一个专业的小偷,计划偷窃沿街的房屋。每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警。 给定一个代表每个房屋存放金额的非负整数数组,计算你 阅读全文
摘要:
@Test public void testChangeStudents() { List<Student> students = new ArrayList<Student>() {{ add(Student.builder().age(50).build()); add(Student.buil 阅读全文
摘要:
ParameterizedType ParameterizedType represents a parameterized type such as Collection 源码: public interface ParameterizedType extends Type { /** * Ret 阅读全文