Core Java

Java 8 map () vs flatMap()

Introduction: Java 8 map() and flatMap() operations can be applied to either Streams or Optional. Stream<T> can be thought of as a wrapper holding a sequence of objects of type T to help us operate over them. Similarly, Optional<T> in Java 8 adds a layer to the top of element T, to help us determine […]

Be the First to comment. Read More
Core Java

BigInteger and BigDecimal In Java

Introduction: In this quick guide, we’ll introduce you to BigInteger and BigDecimal classes in Java. BigInteger: java.math.BigInteger is an immutable class which is used when we need to store and operate on very large integer values. Consider writing a program involving typical mathematical calculations which probably might end up with a very large integral outcome. […]

Be the First to comment. Read More
Core Java

Prime Numbers Generation In Java

Introduction: A prime number is a natural number greater than 1 having only two factors – 1 and the number itself. For eg: 2, 3, 5, 7, 11 etc are all prime numbers. Numbers that are not prime are known as composite numbers. In this tutorial, we’ll learn how to generate all prime numbers less […]

Be the First to comment. Read More
Core Java

Java – Generate Random Integer In Given Range

Introduction: Today we’ll learn ways in which we can generate a random integer in a given range – minValue to maxValue, both inclusive in Java. It is a common requirement we come across while writing some algorithmic solutions. So let’s get started! Generating Random Integer: Using Math.random() : A traditional solution to generate a random […]

Be the First to comment. Read More
Core Java

Prime Number Check In Java

Introduction: Prime Number is an integer greater than 1 and only divisible by 1 and itself. For instance – 2, 3, 5, 7, 11, 13 etc are all prime numbers. In other words, any number with only two factors – 1 and the number itself is known as a prime number. Numbers like 4, 8, […]

Be the First to comment. Read More
Other Tutorials

Git Merge vs Git Rebase

Introduction: Git Merging and Rebasing are two important concepts in understanding how Git works. In this tutorial, we’ll learn the difference between git merge and git rebase. We’ll also learn the cases when we must avoid rebasing. Setup: To follow up with this tutorial, we’ll assume: We have two branches – master and feature. Post […]

Be the First to comment. Read More
Core Java

Sorting In Java

Introduction: In this tutorial, we’ll learn how to sort arrays as well as collections like List, Set, and Map using Java API. Sorting Arrays: Java exposes java.util.Arrays.sort() API which helps us to sort our arrays. There are two flavors to it:

Let’s look at some examples:

Clearly, Arrays.sort(array, fromIndex, toIndex) sorts the […]

Be the First to comment. Read More
Other Tutorials

Git – Adding changes to your last commit

Introduction: While using Git, we all have come across situations when we feel the need of modifying our last commit before we can finally push our code changes. In this quick tutorial, we’ll learn how can we amend our last commit which has not yet been pushed to the remote repository. Use Cases: Modifying Last […]

Be the First to comment. Read More
Core Java

Java Wrapper Classes

Introduction: java.lang package provides a wrapper class for each of the primitive data types. Since Java is an object-oriented language, these wrapper classes help us in treating our primitives much like any other Java object. All wrapper classes are final. Also, the objects instantiated of these wrapper classes are immutable i.e. the value stored within […]

Be the First to comment. Read More
Core Java

Java Enum

Introduction: Java Enum is a Java type which is used to define a fixed set of constants.  For instance, if we wish to store the names of all the months like JANUARY, FEBRUARY, MARCH etc we should prefer creating an enum to hold it. In this tutorial, we’ll learn why using Enums is a good […]

Be the First to comment. Read More