Unveiling the Magic of Java ServiceLoader API: Building Modular and...
In the vast realm of Java programming, developers are often faced with the challenge of creating modular, extensible, and maintainable applications. As software systems grow in complexity, the need to...
View ArticleGotcha: Using Apache Commons StringUtils.isNumeric
StringUtils java class in Apache commons library provides a method isNumeric to check if given sequence of characters contains digits only. But this is not a sure shot way to check for numbers because...
View ArticleThe correct way to do @Async in Java Spring based applications
Spring provides an annotation @Async to run tasks in a separate thread. In Spring boot applications we can enable asynchronous tasks by adding the annotation @EnableAsync to any of the Spring...
View ArticleSetting value of XSL parameter xsl:param in Saxon Java API
In one of my previous posts I showed you how to generate HTML from XML data using XSLT. At times you would need to pass certain parameters to the XSLT and use the value of that parameter in generating...
View ArticleConvert XML to HTML using XSLT in Java
In this post I will show you how to convert XML to HTML using XSLT in Java using Saxon HE version 11 library We will add the dependency to our pom: <dependency>...
View ArticleIntegrate with OpenAI(ChatGPT) Chat Completion API in Java using Webclient
In my previous post I showed how you can integrate with Completion API. The completion API doesnt support the ChatpGPT model. The ChatGPT model is supported in the Chat completion API. In this post we...
View ArticleIntegrate with OpenAI(ChatGPT) Completion API in Java using WebClient
By now you all would have heard about OpenAI and played with its famous product ChatGPT. OpenAI also provides APIs which can be used to integrate features like text completion, code generation, image...
View ArticleJava 17 – Sealed classes
Prior to Sealed Classes feature there were two ways a developer could prevent a class to be extended: by declaring the class as final where no one can extend this class. public final class MyClass { }...
View ArticleJava 16 – Pattern matching for instanceof
We all have used instanceof check with a subsequent cast to the desired type and in this process, we are doing two operations: validating whether the object we have is of the desired type using...
View ArticleJava 16 – Records and Constructor
In my previous post, I introduced you to the new construct called Records which was introduced in Java 16. In this post, I will go a bit deeper into how you can override the default constructor of a...
View ArticleJava 16 – Records
We all, Java programmers, have complained whenever we were forced to create a class or use maps just to hold some data whilst other newer languages provided some out-of-the-box data structure for the...
View ArticleJava 15 – Text blocks
Text blocks are all about writing multi-line strings in a clean and readable way. This was added as part of JEP 378 in Java 15. One can read the detailed information of the feature from the JEP...
View ArticleDifference between Function.andThen and Function.compose
There are two different ways to mix functions in Java: using andThen using compose It is important to understand the difference between the two. andThen: function1.andThen(function2) will first apply...
View ArticleDifferent ways of declaration and initialization of arrays in Java
The below code shows the different ways one can declare and initialize an Array in Java: import java.util.Arrays; public class ArraysDemo { public static void main(String[] args) { int[] a1 = new...
View ArticleJava 17 – Sealed classes
Prior to Sealed Classes feature there were two ways a developer could prevent a class to be extended: by declaring the class as final where no one can extend this class. public final class MyClass { }...
View ArticleJava 16 – Pattern matching for instanceof
We all have used instanceof check with a subsequent cast to the desired type and in this process, we are doing two operations: validating whether the object we have is of the desired type using...
View ArticleJava 16 – Records and Constructor
In my previous post, I introduced you to the new construct called Records which was introduced in Java 16. In this post, I will go a bit deeper into how you can override the default constructor of a...
View ArticleJava 16 – Records
We all, Java programmers, have complained whenever we were forced to create a class or use maps just to hold some data whilst other newer languages provided some out-of-the-box data structure for the...
View ArticleJava 15 – Text blocks
Text blocks are all about writing multi-line strings in a clean and readable way. This was added as part of JEP 378 in Java 15. One can read the detailed information of the feature from the JEP...
View ArticleDifference between Function.andThen and Function.compose
There are two different ways to mix functions in Java: using andThen using compose It is important to understand the difference between the two. andThen: function1.andThen(function2) will first apply...
View Article