Quantcast
Channel: Baeldung
Browsing all 3589 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Verify That Lambda Expression Was Called Using Mockito

1. Overview In this tutorial, we’ll look at how we can test that our code calls a lambda function. There are two approaches to achieving this goal to consider. We’ll first check that the lambda is...

View Article


Image may be NSFW.
Clik here to view.

Deserializing JSON to Java Record using Gson

1. Introduction Thе dеsеrialization procеss involvеs convеrting a JSON rеprеsеntation of an objеct (or data) into an еquivalеnt objеct in a programming languagе, such as a Java objеct. Gson, a popular...

View Article


Image may be NSFW.
Clik here to view.

String vs StringBuffer Comparison in Java

1. Overview String and StringBuffer are two important classes used while working with strings in Java. In simple words, a string is a sequence of characters. For example, “java”, “spring” and so on....

View Article

Image may be NSFW.
Clik here to view.

Static Final Variables in Java

1. Overview Simply put, static final variables, also called constants, are key features in Java to create a class variable that won’t change after initialization. However, in the case of a static final...

View Article

Image may be NSFW.
Clik here to view.

Differences Between Entities and DTOs

1. Overview In the realm of software development, there is a clear distinction between entities and DTOs (Data Transfer Objects). Understanding their precise roles and differences can help us build...

View Article


Image may be NSFW.
Clik here to view.

Handling NullPointerException in findFirst() When the First Element Is Null

1. Overview In this short tutorial, we’ll explore different ways of avoiding NullPointerException when working with the findFirst() method. First, we’ll explain what causes the method to fail with...

View Article

Image may be NSFW.
Clik here to view.

Skip Bytes in InputStream in Java

1. Introduction In Java programming, InputStrеam is a fundamеntal class for rеading bytеs from a sourcе. Howеvеr, thеrе arе scеnarios whеrе it bеcomеs nеcеssary to skip a cеrtain numbеr of bytеs within...

View Article

Image may be NSFW.
Clik here to view.

Java Weekly, Issue 520

1. Spring and Java >> JEP targeted to JDK 22: 464: Scoped Values (Second Preview) [openjdk.org] Another preview of Scoped Values: a safe and efficient way of sharing immutable data within and...

View Article


Image may be NSFW.
Clik here to view.

A Guide to Timefold Solver for Employee Scheduling

1. Overview 1.1. What Is Timefold Solver? Timefold Solver is a pure Java planning solver AI. Timefold optimizes planning problems, such as the vehicle routing problem (VRP), maintenance scheduling, job...

View Article


Image may be NSFW.
Clik here to view.

Recursively Sum the Integers in an Array

1. Overview When we work with numbers, summing all integers in an array is a common operation. Also, recursion often lends itself to elegant solutions. In this tutorial, we’ll explore how to sum...

View Article

Image may be NSFW.
Clik here to view.

BigDecimal.ZERO vs. new BigDecimal(0)

1. Overview When we work with BigDecimal, representing the numerical value zero using BigDecimal is a common task. However, we’re often faced with a choice between two similar approaches: using...

View Article

Image may be NSFW.
Clik here to view.

Convert an OutputStream to a Byte Array in Java

1. Introduction Dealing with strеams is a common task, еspеcially when working with input and output opеrations. Occasionally, the need arises to convеrt an OutputStrеam into a bytе array. This can be...

View Article

Image may be NSFW.
Clik here to view.

Callbacks in ListenableFuture and CompletableFuture

1. Overview ListenableFuture and CompletableFuture are built on top of Java’s Future interface. The former is part of Google’s Guava library, whereas the latter is part of Java 8. As we know, the...

View Article


Image may be NSFW.
Clik here to view.

Creating a Kafka Listener Using the Consumer API

1. Overview In this tutorial, we’ll learn how to create a Kafka listener and consume messages from a topic using Kafka’s Consumer API. After that, we’ll test our implementation using the Producer API...

View Article

Image may be NSFW.
Clik here to view.

Detect the Last Iteration in for Loops in Java

1. Overview The for-each loop is an elegant and simple tool when we iterate over a List. Sometimes, there are scenarios where we need to perform specific actions or make decisions based on whether an...

View Article


Image may be NSFW.
Clik here to view.

Convert a String to a List of Characters in Java

1. Introduction Java offеrs sеvеral ways to manipulatе strings. In this tutorial, wе’ll еxplorе onе common rеquirеmеnt of convеrting a string into a list of charactеrs. 2. Using toCharArray() Thе...

View Article

Image may be NSFW.
Clik here to view.

Lazy Field Initialization with Lambdas

1. Introduction Frequently, when we work with resources that require the execution of expensive or slow methods, such as database queries or REST calls, we tend to use local caches or private fields....

View Article


Image may be NSFW.
Clik here to view.

Reactor WebFlux vs Virtual Threads

1. Overview In this tutorial, we’ll compare Java 19’s virtual threads with Project Reactor’s Webflux. We’ll begin by revisiting the fundamental workings of each approach, and subsequently, we’ll...

View Article

Image may be NSFW.
Clik here to view.

What Does It Mean to Hydrate an Object?

1. Introduction In this tutorial, we’ll talk about the term hydration in the context of programming and dive deep into what it means to hydrate a Java object.  2. Object Hydration 2.1. Lazy...

View Article

Image may be NSFW.
Clik here to view.

Convert Excel Files to PDF Using Java

1. Introduction In this article, we’ll explore how to convert Excel files to PDF in Java using the Apache POI and iText libraries. Apache POI handles Excel file parsing and data extraction, while iText...

View Article
Browsing all 3589 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>