Initialization List with values in one row in Java

Java 9: List.of(“a”, “b”, “c”); Set.of(“a”, “b”, “c”); Java 8: Stream.of(“a”, “b”, “c”).collect(Collectors.toList()); Stream.of(“a”, “b”, “c”).collect(Collectors.toCollection(ArrayList::new)); Older: Collections.singletonList(); Arrays.asList(); new ArrayList() {{ add(“a”); add(“b”); add(“c”); }};


JVM JVM memory model Java8 Heap Memory – store objects two different areas called the “Young Generation Space” (is divided into two portions called “Eden Space” and “Survivor Space: S0 and S1″) “Tenured Space“ (Old Generation Space) Meta Space (Perm Gen Space <Java8) Code Cache References strong weak soft phantom Garbage Collector Garbage Collector Serial […]

Java Primitives Types



Immutable – create new one (> -XX:AutoBoxCacheMax)

Integer cache (autoboxing and cashing with Integer.valueOf(int))

Integer Generics Collections Autoboxing

JVM – Memory Model in Java

Heap – java.lang.OutOfMemoryError Young Gen: Eden Space – newly created object, minor GC moving to the one of Survivor after clening, fast Stop the World, Young Gen: Survivor Space (S0, S1) – moving from one survivor to another, clean up, one of the Survivor is always empty, survived after many GC moved to Old Old Gen: […]

Enum Types

Enum is thread safe has own namespace can use inside switch constructor of Enum is private adding new constant is easily constants defined in Enum are implicitly static and final, can be compared with == Java generate values() method Enum can implement interface Abstract method can be defined in Enum EnumMap EnumSet declare

use […]