Core Java

How to Handle Daylight Savings In Java

Introduction: Daylight Savings, often referred to as DST, is a practice of advancing the clocks during summer months to use the natural daylight a little longer. The clock is again adjusted backwards during fall to match the standard clock. The concept of Daylight Savings is used by many countries and therefore must be taken into […]

2 comments Read More
Core Java

TreeSet In Java

Introduction: TreeSet in Java is a sorted set of items stored in a tree-like structure. It implements the NavigableSet interface and extends AbstractSet class. Some of the properties of TreeSet includes: Unique collection of items Elements stored in a sorted order Faster access and retrieval of items The default ordering in a TreeSet is in […]

Be the First to comment. Read More
Core Java

Java 8 Optional

Introduction: java.util.Optional class defined in Java 8 can be thought of as a container class for storing and handling not – null objects. When working with an Optional, a null value is usually represented as an absent value instead. The Optional class exposes various methods to help us treat values as either ‘Available’ or ‘Unavailable’. […]

Be the First to comment. Read More
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 […]

One 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: public static void sort(type[] arr) //sorts array in range [fromIndex – toIndex) : toIndex […]

Be the First to comment. Read More