JVM Structure Overview. Memory Distribution

The JVM greatly simplifies and automates memory handling in Java programs. The programmer simply declares variables without even worrying about how the occupied memory will be freed. Although in some cases a random memory leak can occur, where the program will just start devouring memory in large amounts, in most cases everything happens automatically and without problems. Memory Types Allocation Generally speaking, the JVM allocates memory into a stack and a heap. Every Java program has at least one parent process and every process has one main thread. In turn,…

Read More

Optional in Java Overview

Java Optional – represents a container object that may or may not contain a non-null value. If the value is present isPresent returns true otherwise false will be returned and the object will be considered empty. Previously, we wrote about immutable objects, which are also used under the hood of optionals. Initialize Java 8 Optional The optional can be initialized using the static constructor as follows: If you put a null value to such a constructor, a java.lang.NullPointerException will occur. You can use the ofNullable method to safely pass an…

Read More

Design and Build REST Multi-Module Spring Boot Project

This article explains how to create multi module Spring Boot project with different approaches. We will consider the usage of Spring Initializr, IntelliJ new module creation and how to create a new module in Eclipse. What Benefits We Achieve in Multi Module Project By following the best practices in programming, especially SOLID principals we can achieve clean architecture of the application. One of principals is Dependency Inversion. This principal advices to avoid linking for application units without additional layer. Let us consider with more detail this principal. How to Create…

Read More