Java Weekly, Issue 516
1. Spring and Java >> Table partitioning with Spring and Hibernate [vladmihalcea.com] Splitting a large table into multiple smaller partition tables using Spring and Hibernate — allowing a more...
View ArticleHow to Effectively Unit Test CompletableFuture
1. Introduction CompletableFuture is a powerful tool for asynchronous programming in Java. It provides a convenient way to chain asynchronous tasks together and handle their results. It is commonly...
View ArticleGet Index of First Element Matching Boolean Using Java Streams
1. Introduction Finding the index of an element from a data structure is a common task for developers. In this tutorial, we’ll use the Java Stream API and third-party libraries to find the index of the...
View ArticleString’s Maximum Length in Java
1. Introduction Onе of thе fundamеntal data typеs in Java is thе String class, which rеprеsеnts a sеquеncе of charactеrs. Howеvеr, undеrstanding thе maximum lеngth of a String in Java is crucial for...
View ArticleSpring Kafka Trusted Packages Feature
1. Introduction In this tutorial, we’ll review the Spring Kafka trusted packages feature. We’ll see the motivation behind it, along with its usage. All with practical examples, as always. 2....
View ArticleUnderstanding NewSQL Databases
1. Overview Databases are one of the ways we store collections of data and there are different types of databases available. Different DBMSs, such as SQL and NoSQL databases, became popular based on...
View ArticleVerify 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 ArticleDeserializing 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 ArticleString 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 ArticleStatic 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 ArticleDifferences 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 ArticleHandling 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 ArticleSkip 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 ArticleJava 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 ArticleA 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 ArticleRecursively 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 ArticleBigDecimal.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 ArticleConvert 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 ArticleCallbacks 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 ArticleCreating 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