Ever wondered why some parts of your Java code using collections mysteriously crash? It all boils down to how those collections handle null values! Learn the hidden rules behind ArrayLists, HashSets, TreeMaps, HashMaps, and null values.
Also find me here:
Baeldung Editor
Luis Javier Peris
Javier is a computer science engineer with more than 12 years of experience. Passionate about product development under agile and devops principles, having exercised the role of Scrum Master and Agile Coach for more than 10 years. His other great passion is software craftsmanship with a focus on clean code, DDD, hexagonal architecture and great testing practices.
Here's what I've reviewed (so far):
Baeldung on Java
- All
- Java IO (11)
- Java (11)
- Core Java (11)
- Java String (9)
- Persistence (8)
- Java Dates (8)
- Spring Data (7)
- Spring Boot (7)
- REST (5)
- NoSQL (5)
- Java Numbers (5)
- Spring Web (4)
- Spring Persistence (4)
- Spring (4)
- Reactive (4)
- Java Collections (4)
- Java Array (4)
- Algorithms (4)
- Java List (3)
- Java Concurrency (3)
- Jackson (3)
- Gradle (3)
- Testing (2)
- Spring Security (2)
- Spring Cloud (2)
- Logging (2)
- Java Streams (2)
- JPA (2)
- HTTP Client-Side (2)
- Data (2)
- Web Services (1)
- Spring WebFlux (1)
- Spring MVC (1)
- Security (1)
- Networking (1)
- Maven (1)
- Java Map (1)
- JSON (1)
- IDE (1)
- Docker (1)
- DevOps (1)
- Artificial Intelligence (1)
Fix the JsonMappingException: Can not deserialize instance of java.util.HashMap out of START_ARRAY token
Filed under Jackson
Ever encountered this cryptic error while working with Jackson? This article sheds light on its root cause and provides practical solutions. Learn how to effectively handle JSON arrays and avoid common pitfalls when deserializing into Java objects.
Streaming Real-Time Log to Splunk From Spring Boot
Filed under Logging
Tired of sifting through endless log files? This tutorial dives into seamlessly integrating Splunk, a powerful monitoring tool, with your Spring Boot application to achieve real-time log streaming.
Count Inversions in an Array in Java
Filed under Algorithms, Java Array
Ever wondered how to measure the disorder of an array? Inversions hold the key! Learn to count inversions using brute-force and divide-and-conquer methods.
Guide to Using the JMeter Beanshell
Filed under Testing
Dive into the world of advanced test scripting with JMeter and BeanShell from generating dynamic request data to aggregating performance metrics.
Introduction to JavaMelody
Filed under DevOps
Learn to use JavaMelody to monitor Java applications.
How to use virtual threads with ScheduledExecutorService
Filed under Java Concurrency
Tired of limitations with traditional threading in Java? Virtual threads, a new feature in JDK 21, offer a lightweight alternative that explodes concurrency possibilities.
Pass Collection as Varargs Argument
Filed under Java Collections
Ever found yourself writing multiple overloaded methods just to handle different numbers of arguments? Java’s varargs feature might be the elegant solution you’ve been looking for.
Introduction to Apache Commons Validator
Filed under Java
Learn how to validate dates, numbers, currencies, and more with built-in validators, saving you time and ensuring consistent validation across your application.
Baeldung on Linux
- All
- Scripting (4)
- Administration (3)
- Security (2)
- Processes (2)
- Network Configuration (2)
- Filesystems (2)
- Web (1)
- User Administration (1)
- Search (1)
- Networking (1)
- Installation (1)
- Files (1)
- File Compression (1)
How to Find Memory Leak of a Running Process in Linux
Filed under Processes
Learn about tools like htop, /proc, pmap, smem, memleax, and gdb, that provide insights into memory usage and help identify leaks.
Running Scripts at a X-Second Interval
Filed under Scripting
Explore different approaches to running a script at regular intervals.
Guide to Linux df Command With Examples
Filed under Filesystems
Explore practical examples of using the df command to manage disk space effectively.
How to Set up and Install Intellij With JDK in Linux
Filed under Installation
Learn to install and configure IntelliJ IDEA with Java Development Kit.
Compression of Multiple Files Individually With gzip
Filed under File Compression
Learn how to use the gzip and gunzip utilities to compress and uncompress files and folders from the command line in Linux. Explore compressing individual files and multiple files in subdirectories using wildcard expansion. Further, discover alternatives to gzip, such as Zip and 7-Zip, and learn about their advantages and differences.
How to Find Filenames That End With a Number in Bash
Filed under Files
This tutorial explores different methods in Bash for finding files with numbered names and processing them efficiently. It covers using wildcards and regular expressions to match numbers at the end of file names, filtering files based on specific criteria, retrieving numbers from file names, and executing commands on the matched files.
How to Automate Mouse Movements Using the Command Line
Filed under Administration
Learn how to use xdotool commands such as mousemove, click, and mousedrag to simulate mouse actions, perform complex operations, and add delays between commands. This tutorial is your go-to resource for efficient mouse automation using xdotool.
Standard Error Codes in Linux
Filed under Processes
This article explores standard error codes in Linux, their significance, and how they aid in troubleshooting since they indicate the cause and type of an error during program or command execution.
How to Set up an SSTP Server on Linux
Filed under Networking
This tutorial is a guide on how to configure a Secure Socket Tunneling Protocol (SSTP) VPN server on Linux using SoftEther VPN Server, an open-source and freeware cross-platform multi-protocol VPN implementation. It covers the installation and configuration of SoftEther VPN on Linux, including software requirements, downloading, compiling the server, and its verification.
Baeldung on Scala
- All
- Scala Collections (3)
- Scala Strings (1)
How to Check if a String Is Null or Empty in Scala
Filed under Scala Strings
This tutorial explores efficient methods to check if a string or collection is empty in Scala 3. We discuss using isEmpty, isBlank, and nonEmpty methods, noting their limitations with null values.
Merge Two Maps in Scala
Filed under Scala Collections
Learn how to merge two maps in Scala.
Split a Sequence in Scala
Filed under Scala Collections
How to split a sequence using the partition, span, or groupBy functions.
Create an Empty Array in Scala
Filed under Scala Collections
Different ways of creating an empty array in Scala.
Baeldung on Kotlin
- All
- Spring (3)
- Patterns (2)
- Kotlin-Java Interop (1)
- Kotlin Dates (1)
- Kotlin Collections (1)
- Kotlin Classes and Objects (1)
- Kotlin Basics (1)
Converting a Custom Object List to Simple List in Kotlin
Filed under Kotlin Basics, Kotlin Collections
This article demonstrates how to convert a list of objects into a list of strings in Kotlin using various methods, including map(), mapNotNull(), mapTo(), mapIndexed(), for loops, and flatMap().
The Adapter Pattern in Kotlin
Filed under Patterns
The article introduces the Adapter Pattern in Kotlin, a design pattern that enables collaboration between classes with incompatible interfaces. We use an Audio Player example to demonstrate how the pattern works.
Spring Dependency Injection With Kotlin
Filed under Spring
This article discusses Spring dependency injection options available with Kotlin, including Spring’s @Autowired annotation for injecting components. The article provides examples of each option and concludes by emphasizing the importance of proper dependency injection in Kotlin.
Convert Java to Kotlin
Filed under Kotlin-Java Interop
This article explores various ways of converting Java code to Kotlin code, including using IntelliJ IDE or Android Studio, an online tool called JavaInUse, and the advantages of Kotlin over Java. It also discusses the limitations of each method and provides recommendations for when to use them.
Singleton Classes in Kotlin
Filed under Kotlin Classes and Objects, Patterns
What’s a singleton and how to create single instance in Kotlin.
Difference Between Two Dates in Kotlin
Filed under Kotlin Dates
A quick example of how to calculate the difference between two dates using Java 8 built-in classes and Joda time.
Kotlin and Spring Boot @ConfigurationProperties
Filed under Spring
Explore different ways of using Spring @ConfigurationProperties with Kotlin classes.
Spring Boot and Kotlin
Filed under Spring
Learn how to use Kotlin together with Spring Boot 2.x.
Baeldung on Ops
- All
- Docker (2)
- Kubernetes (1)
- Jenkins (1)
- Git (1)
Recover a Git Branch After Its Deletion
Filed under Git
Accidentally deleted a Git branch? Don’t panic! This tutorial shows you how to recover it using the reflog and git fsck. Even if the branch is gone, its commits might still be recoverable.
Removing Files and Directories in Different Docker Layers
Filed under Docker
In this article, we explore several approaches to effectively removing directories across layers, ensuring they’re fully eliminated from the final image.
Using `kubectl ls` or Alternative Methods to Inspect a Kubernetes Pod
Filed under Kubernetes
This article outlines various methods for inspecting files within Kubernetes pods, a crucial skill for DevOps troubleshooting and maintenance. It covers three main approaches: using the kubectl exec command, accessing container filesystems from the host node, and utilizing interactive shells.
Send Email Notification From Jenkins
Filed under Jenkins
An extensive example about how to configure two different options to send emails using Jenkins.
Running Docker Containers Indefinitely
Filed under Docker
A brief explanation about entrypoint and cmd to understand when a container terminates and how we can prevent it.