How to Enable Spring Data MongoDB Auto Index Creation

Overview If you have tried setting auto-index-creation in spring data mongodb without success, like this: Then this post will show you how to work around this. Let’s get started. Enable auto index creation in MongoDB First, let’s consider this document Here, I defined an unique index for my document named rate_limit_config_service_name but when the application … Read more

6 Ways To Directly Initialize a HashMap in Java

Java provides several ways to initialize a HashMap directly, making your code more concise and readable. In this blog post, we’ll explore different methods to create and populate a HashMap in one go using Java. 1. Using Map.of() (Java 9+) For small, immutable maps, you can use the Map.of() method: This method is convenient but … Read more

Working With Currency Data In Java

Overview Working with currency data in Java involves several key aspects: conversion rates, formatting, rounding, and arithmetic operations. This article will guide you through handling these aspects effectively in Java, ensuring accurate and reliable financial applications. Conversion Rates To handle currency conversion, you can use external APIs like the ExchangeRate-API. This API allows you to … Read more

Using FFMPEG in Java Cheat Sheet

Overview This cheat sheet contains code example that I use most frequently in my recent project that uses ffmpeg extensively to edit and create video. Let’s get started. Run ffmpeg in Java To run a ffmpeg command from Java, use the following function. Create a video from a single image with a duration To create … Read more

Understanding == and equals() in Java

Overview In Java, the == operator and the equals() method are both used to compare objects, but they serve different purposes and operate in fundamentally different ways. Stack, Heap, and References Before delving into the differences between == and equals, first, you need to understand what are references and how they are stored and used in Java. References and … Read more