1、引用jol-core依赖
jol-core依赖版本的不同,下面代码分析的结果样式是不同的,下面再展示不同版本的结果
<dependency>
<groupId>org.openjdk.jol</groupId>
<artifactId>jol-core</artifactId>
<version>0.16</version>
<!-- <scope>provided</scope>-->
</dependency>
2、代码分析
import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.info.GraphLayout;
import org.openjdk.jol.vm.VM;
public class test {
public static void main(String[] args) {
String s = "-1111111111111111111111111011011011110110100001001010001011110111";
// String s = "- 11111111【】 11111111【】 11111111【】 10110110【b6】 11110110【f6】 10000100【84】 10100010【a2】 11110111【f7】";
String b1 = "11110111";
System.out.println("s的长度是="+s.length());
System.out.println("=============================");
Person person = new Person();
// int hashCode = person.hashCode();
System.out.println(VM.current().details());
System.out.println("==========

最低0.47元/天 解锁文章
2495

被折叠的 条评论
为什么被折叠?



