Junit 5 Parameterized Tests Examples

Introduction In this example we will create Junit 5 parameterized tests. In our previous example we have seen how to configure Junit 5 for Java projects. In parameterized tests it is possible to run a test multiple times with different arguments. The @ParameterizedTest annotation is used in the regular @Test methods to indicate parameterized tests. In addition, at least one…

Reverse A String Without Affecting Special Characters Using Java

String with special characters In this tutorial you will see how to reverse a string without affecting special characters using Java programming language. You will also see in this example how to check whether a character is alphabet or digit or special character. Your string may contain special characters such as $, #, @ etc. and you don’t want to…

Find largest product of two elements in an array using Java

Introduction In this example we will see how to find largest product of two elements in an array using Java language. In other hand you can also find those two elements for which the largest product is computed among the elements of an array. The elements are assumed to be integer in an array. The element may be 0 or…

How to count Words, Paragraphs, Sentences, Characters, White Spaces in a Text File using Java

Introduction Here I will create a sample program to count words, paragraphs, sentences, characters, white spaces in a text file using Java programming language. In this tutorial I will read a simple text file and count number of words, paragraphs, characters etc.

How To Group Objects By Their Property Using Java 8 Stream

Introduction Here you will see an example on how to group objects by their property using Java 8 stream API. GROUP BY is a very useful aggregate operation in SQL, which allows us to group records on certain criteria and Java 8 or later version of Java directly allows you to do GROUP BY in Java by using Collectors.groupingBy() method….

How To Verify A String Is Palindrome In Java

Introduction In this tutorial I will check how to verify a string is palindrome or not using Java programming language. A palindrome is a technique, where a word, phrase, or sequence that reads the same backwards as forwards. For example, ehcache, madam, etc are examples of palindrome. Prerequisites Java Check Palindrome I will use here few techniques to present how…

How to log with Lombok using @slf4j annotation in Java, Spring and Spring Boot Applications

Introduction In this tutorial I will show you how to configure Lombok for logging using @slf4j annotation in Java, Spring and Spring Boot applications. The example shown here will work for Java, Spring and Spring Boot applications. This annotation will reduce the code you write for creating logger variable. Lombok will provide log variable when you use @slf4j annotation on…

Spring Module-Wise Logs Using MDC In Logback

SiftingAppender And MDC In this example you will see how to create or generate separate log file module-wise or for each separate functionality using SiftingAppender in logback with the help of ThreadedContext or MDC in Spring Boot applications. MDC also known as Mapped Diagnostic Context is a lighter technique consists of uniquely stamping each log request servicing a given client….

How to create separate log file for each module using RoutingAppender and MDC (Mapped Diagnostic Context) in log4j2/slf4j

Introduction In this example we will see how to create or generate separate log file module-wise or for each separate functionality using RoutingAppender in log4j2 with the help of ThreadedContext or MDC. MDC or Mapped Diagnostic Context is a lighter technique consists of uniquely stamping each log request servicing a given client. To uniquely stamp each request, the user puts…

Generate Line Chart In Excel Using Apache POI

Line Chart In this tutorial I will show you how to create line chart in excel file using Java based Apache POI library. I will also show you how to build this application using both maven and gradle build tools. This is a standalone application and you can use this concept of line chart generation in any Java based application….