Category: Core Java

Core Java

Java 8 Stream Collectors

Introduction: Java 8 Streams is a powerful feature introduced in Java 8. To learn more about Streams in Java, we’ll suggest you read this post. In this tutorial, we’ll cover how to collect the output stream into one of the known Collection types followed by exploring a few other Collectors options. We’ll be reusing the […]

Be the First to comment. Read More
Core Java

Introduction to Java 8 Stream API

Introduction: Java 8 introduced functional programming and the concept of streams and functional interfaces to back it. As the name suggests, Java 8 Stream can be thought of as a stream or source of data to operate on. For this tutorial, we assume the reader to have an understanding of Java Optional and Functional Interface. […]

Be the First to comment. Read More
Core Java

Remove All Occurrences Of Newline From byte Array

Introduction: In this article, we’ll uncover ways in which we can remove all line breaks or newline characters from a byte array in Java. For this tutorial, we are assuming line breaks for our system would mean “\n” character(usually true for a Unix environment). Removing Line-Breaks from byte Array: 1. Using java.lang.String: An easy implementation […]

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