Multi-layered applications often require to map between different object models (e.g. entities and DTOs). Writing such mapping code is a tedious and error-prone task. MapStruct aims at simplifying this work by automating it as much as possible. In this post, I will give you an overview of MapStruct and the steps needed to integrate it into your project.
Many Java applications have dependencies that aren’t available in a public or private Maven repository. Sometimes you may have just a third party java library, packaged as a jar, that you need to integrate in your application. This is very common when you have Oracle as your database and you need to connect to the db using the ojdbc.jar which is not available in maven central repository. You need to download it from Oracle website and then need to integrate it in the maven project as a third party dependency.
In this post, I will show how to add a third party client jar to a maven project.
In this post, I will demonstrate a simple java program, I recently faced, to encode a string to a specific requirement and later I will also show how to decode it back. Lets have a look at the requirement. You need to encode a string having the consecutive repetitive characters with the character itself followed […]
A prime number (or a prime) is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1, involve 5 itself. However, 6 is composite because it is the product of two numbers (2 × 3) that are both smaller than 6. The property of being prime is called primality. A simple method of checking the primality of a given number n, called trial division, tests whether n is a multiple of any integer between 2 and square root of n.
In this post, I will demonstrate how to check primality of a number and then generate a sequence of prime numbers using Java Stream API based on two different criteria.
The Fibonacci numbers are the numbers in an integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones. In this article I am going to show, how to generate fibonacci sequence using Java Stream API and later will discuss about the implementation.
Factorial of a non-negative integer n is multiplication of all integers smaller than or equal to n. In this article, we’re going to see how we can calculate factorial by using Java Stream API.