Added the Boolean Object Size Samples

This commit is contained in:
Ali Dehghani
2020-06-09 02:23:08 +04:30
parent 0710026838
commit 56d186f031
3 changed files with 37 additions and 1 deletions
@@ -0,0 +1,25 @@
package com.baeldung.boolsize;
import org.junit.Test;
import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.vm.VM;
public class BooleanSizeUnitTest {
@Test
public void printingTheVMDetails() {
System.out.println(VM.current().details());
}
@Test
public void printingTheBoolWrapper() {
System.out.println(ClassLayout.parseClass(BooleanWrapper.class).toPrintable());
}
@Test
public void printingTheBoolArray() {
boolean[] value = new boolean[3];
System.out.println(ClassLayout.parseInstance(value).toPrintable());
}
}
@@ -0,0 +1,5 @@
package com.baeldung.boolsize;
class BooleanWrapper {
private boolean value;
}