摘要: public class OuterClass { private int x; public class InnerClass { public void doSomething(){ System.out.println(x); } } } 阅读全文
posted @ 2023-02-12 21:56 八英里 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 1:带有static修饰符的方法,在类加载的时候就已经存在。 2:没有static修饰符的方法,只有在实例化的时候才存在。 阅读全文
posted @ 2023-02-12 21:02 八英里 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 单例各种实现代码 1. 懒汉式单例实现 ```java /** * 懒汉式单例 */ public class LazySingleton { private static LazySingleton instance; private LazySingleton() { } public stat 阅读全文
posted @ 2023-02-12 20:57 八英里 阅读(14) 评论(0) 推荐(0) 编辑
摘要: public class DeadLockDemo { private static Object resource1 = new Object();//资源 1 private static Object resource2 = new Object();//资源 2 public static 阅读全文
posted @ 2023-02-12 20:49 八英里 阅读(22) 评论(0) 推荐(0) 编辑