How to Implement Elvis Operator in Java 8
1. Introduction In Java 8, there is no built-in Elvis operator like in Groovy or Kotlin. However, we can implement our own Elvis operator using method references and the ternary operator. In this...
View ArticleCasting Maps to Complex Objects
1. Overview Manipulating and reconstructing data is often a crucial part of programming in Java. One powerful technique involves casting Map objects into complex objects or POJOs. This can allow us to...
View ArticleAvoiding the IndexOutOfBoundsException When Using List.subList() in Java
1. Overview In this short tutorial, we’ll learn how to avoid IndexOutOfBoundsException when working with the subList() method provided by the List interface. Initially, we’ll discuss how subList()...
View ArticleGet the Position of Key/Value in LinkedHashMap Using Its Key
1. Introduction The LinkedHashMap class provides a convenient way to maintain the insertion order of key-value pairs while still offering the functionality of a HashMap. In this tutorial, we’ll explore...
View ArticleHow to Convert Between java.sql.Timestamp and ZonedDateTime in Java
1. Overview Handling timеstamps in Java is a common task that allows us to manipulatе and display datе and timе information morе еffеctivеly еspеcially when we’re dealing with databasеs or global...
View ArticleCollecting into Map using Collectors.toMap() vs Collectors.groupingBy()
1. Overview In Java programming, working with collections and streams is a common task, especially in modern, functional programming paradigms. Java 8 introduced the Stream API, which provides powerful...
View ArticleFix Spring Boot H2 JdbcSQLSyntaxErrorException “Table not found”
1. Introduction H2 provides a simple in-memory and lightweight database that Spring Boot can configure automatically, making it easy for developers to test data access logic. Typically,...
View ArticleSave Child Objects Automatically Using JPA
1. Overview Sometimes we deal with entities with complex models consisting of parent and child elements. In this scenario, it can be beneficial to save the parent entity, thereby automatically saving...
View ArticleOpenAPI Custom Generator
1. Introduction In this tutorial, we’ll continue to explore OpenAPI Generator‘s customization options. This time, we’ll show how the required steps to create a new generator that creates REST Producer...
View ArticleConverting short to byte[] in Java
1. Introduction Converting a short value to a byte[] array is a common task in Java programming, especially when dealing with binary data or network communication. In this tutorial, we’ll explore...
View ArticleInheritance vs. Composition in JPA
1. Introduction Inheritance and composition are two fundamental concepts in object-oriented programming (OOP) that we can also leverage in JPA for data modeling. In JPA, both inheritance and...
View ArticleFull and Partial Text Search in MongoDB
1. Introduction The need for fast and efficient text searches often arises when developing database applications. They should also support full and partial text matches to make these searches even more...
View ArticleUsing Reactor Mono.cache() for Memoization
1. Overview Optimizing code for performance is a key part of programming, especially when dealing with expensive operations or data retrieval processes. One effective way of improving performance is...
View ArticleConvert an Optional to an ArrayList in Java
1. Introduction Java introduced the Optional class in Java 8 to represent a value that may or may not be present. It helps us to avoid NullPointerException and write more expressive and readable code....
View ArticleHow to Iterate a List of Maps in Java
1. Introduction In Java programming, dealing with collections is a fundamental task. Lists and Maps are two commonly used collection types, and sometimes, we might need to work with a List of Maps....
View ArticleConvert Jackson JsonNode to Typed Collection
1. Overview In this tutorial, we’ll explore different methods of converting Jackson’s raw data type JsonNode into typed Java collections. While we can read JSON using JsonNode itself, converting it to...
View ArticleConvert a Queue to a List
1. Overview In this tutorial, we’ll learn how to convert a Queue object into a List in Java. We’ll explain several popular ways of doing this along with their implementations, and we’ll end each...
View ArticleJava Weekly, Issue 541
1. Spring and Java >> This is not your uncle’s Java! Modelling with Java 22 records pattern matching in practice [event-driven.io] Java has come a long way, but it was definitely worth the wait!...
View ArticlePerform Action Only if All Optionals Are Available
1. Introduction Null references and values have tormented programmers for years. Tony Hoare, the creator of null references, famously called his invention a “billion-dollar mistake.” Java, in...
View ArticleHow to Convert Between ZonedDateTime and Date in Java
1. Overview When working with Java applications that handle date and time, understanding how to convert between different types is often essential. In this tutorial, we’ll explore how to convert...
View Article