Heap Fragmentation: A Guide for Interview

We will cover everything you need to know about heap fragmentation, including why it happens, its impact, how to control it, and how different JVM versions handle it, along with JVM options to manage fragmentation. What is Heap Fragmentation? Heap fragmentation occurs when the free memory in the heap is split into small, scattered blocks. This fragmentation makes it difficult for a program to allocate large chunks of memory, even if the total free memory is adequate....

September 4, 2024 · 6 min · 1172 words · PandaC

Understanding Internal Implementation of HashMap and HashSet in Java

When working with Java, two commonly used data structures are HashMap and HashSet. These collections are highly efficient, but their efficiency relies on how they handle internal operations, especially when it comes to collisions. This blog will explain the internal workings of HashMap and HashSet in simple terms and provide examples to help you understand how they manage collisions. What is a HashMap? A HashMap is a data structure that stores key-value pairs....

August 25, 2024 · 6 min · 1108 words · PandaC

Stack in Java: Interview Guide

1. Introduction to Stack in Java Definition: A stack is a linear data structure that follows the Last In First Out (LIFO) principle. Operations: Push: Adds an element to the top of the stack. Pop: Removes and returns the top element of the stack. Peek: Returns the top element without removing it. isEmpty: Checks if the stack is empty. size: Returns the number of elements in the stack. 2. Implementing a Stack in Java Using java....

July 19, 2024 · 4 min · 712 words · PandaC

Linked Lists in Java: An Interview Guide

Linked lists are a fundamental data structure that every software developer should understand. They form the basis for many other data structures and algorithms. In this blog post, we’ll explore how to implement a linked list in Java and cover some of the trickiest parts that you might encounter during interviews. What is a Linked List? A linked list is a linear data structure where each element, called a node, contains a reference (or link) to the next node in the sequence....

July 7, 2024 · 4 min · 800 words · PandaC