Loading

摘要: 异和异或 认识异或 int a = 7; // 此时a的二进制是 0111 int b = 13; // 此时b的二进制是 1101 那么此刻我们把 a 异或 b 会的到 10 0 1 1 1 1 1 0 1 1 0 1 0 官方点来说是 相同为0 不同为1 简单来记 就是直接想加 不用进位 和同或 阅读全文
posted @ 2022-01-18 21:22 Pen9 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 垃圾回收 1、如何判断对象可以回收 引用计数法 弊端:循环引用时,两个对象的计数都为1,导致两个对象都无法被释放 可达性分析算法 JVM中的垃圾回收器通过可达性分析来探索所有存活的对象 扫描堆中的对象,看能否沿着GC Root对象为起点的引用链找到该对象,如果找不到,则表示可以回收 可以作为GC R 阅读全文
posted @ 2021-11-06 13:08 Pen9 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 类加载与字节码技术 1、类文件结构 首先获得.class字节码文件 方法: 在文本文档里写入java代码(文件名与类名一致),将文件类型改为.java java终端中,执行javac X:...\XXX.java 以下是字节码文件 0000000 ca fe ba be 00 00 00 34 00 阅读全文
posted @ 2021-11-06 13:07 Pen9 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 1. JVM的概述 JVM描述 Java 虚拟机有自己完善的硬件架构,如处理器、堆栈等,还具有相应的指令系统。Java虚拟机本质上就是一个程序,当它在命令行上启动的时候,就开始执行保存在某字节码文件中的指令。Java 语言的可移植性正是建立在 Java 虚拟机的基础上。任何平台只要装有针对于该平台的 阅读全文
posted @ 2021-11-06 13:04 Pen9 阅读(496) 评论(0) 推荐(0) 编辑
摘要: public class ABADemo { private static AtomicReference atomicReference=new AtomicReference<>(100); private static AtomicStampedReference stampedReferen 阅读全文
posted @ 2021-11-06 13:01 Pen9 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 深度剖析volatile 三个概念 原子性:简单理解,对于某个操作来说,要么就全部执行,要么就都不执行,不会存在执行一半后面执行不了。 可见性:指当多个线程访问同一个变量时,一个线程修改了这个变量的值,其他线程能够立即看得到修改的值。 有序性:程序执行的顺序按照代码的先后顺序执行 Java内存模型 阅读全文
posted @ 2021-11-05 16:13 Pen9 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 深入理解锁的前置条件 对象头 什么是对象头 在Hotspot虚拟机中,对象在内存中的布局分为三块区域:对象头、实例数据和对齐填充; Java对象头是实现synchronized的锁对象的基础,一般而言,synchronized使用的锁对象是存储在Java对象头里。 它是轻量级锁和偏向锁的关键 Mar 阅读全文
posted @ 2021-11-04 18:47 Pen9 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 选择排序 public static void selectSort(int[] arr){ //边界判断啊 if(arr == null || arr.length < 2 ){ return ; } int minIndex; //外循环是对1-n 取最小值,2-n 取最小值 for(int i 阅读全文
posted @ 2021-11-03 15:16 Pen9 阅读(38) 评论(0) 推荐(0) 编辑
摘要: Convert Binary Number in a Linked List to Integer Given head which is a reference node to a singly-linked list. The value of each node in the linked l 阅读全文
posted @ 2021-09-23 14:36 Pen9 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 面试题 02.02. Kth Node From End of List LCCI Implement an algorithm to find the kth to last element of a singly linked list. Return the value of the elem 阅读全文
posted @ 2021-09-22 11:25 Pen9 阅读(33) 评论(0) 推荐(0) 编辑