Home » Core Java

Core Java

Java Ternary Operator Example

1. Introduction The word “ternary“, in mathematical terms, is an operation that takes 3 variables and, when combined, produces a single output. In Java, as in other languages such as JavaScript or Python, the ternary, or conditional operator, is the only operator that takes 3 operands and produces a value. In this example we will examine the syntax and the ...

Read More »

Java Binary Search Tree Example

1. Introduction A binary tree is a recursive data structure where each node can have at most two children. A binary search tree (BST) is a special type of binary tree which has the following properties: The left sub-tree of a node contains the nodes with the key’s value lesser than itself.The right sub-tree of a node contains the nodes ...

Read More »

Java Round Number to N Decimal Places Example

In this example, we are going to show how we can round a decimal number in Java. Before going in details let us brief you about what exactly is the rounding a number means. 1. What is rounded Number A rounded number has about the same value as the original number we started with. It is less exact than the ...

Read More »

Java Math.pow Example

In this article, we examine the Java Math.pow method and we provide some examples of its use. 1. Introduction The java.lang package provides classes and interfaces that are central to the Java programming language. The Math class from the java.lang package contains static methods for performing many common math operations. These include exponential, logarithm, square root, and trigonometric functions. One ...

Read More »

Gradle Grails Example

1. Introduction This is an in-depth article on Gradle Grails projects. Gradle is a build management system which is open-sourced. The scripts are developed using Groovy or Kotlin DSL for managing builds. Grails is an opensource framework for developing full stack applications. 2. Gradle Grails 2.1 Prerequisites Java 8 is required on the linux, windows or mac operating system. Gradle ...

Read More »

Java 12 String Methods Example

In this article, we will discuss the new methods of the String class introduced in Java SE 12. 1. Introduction The latest Java release (Java SE 12) arrives on the heels of Java SE 11, due to the twice-annual release schedule. It is more akin to a point release than a major release, with only minor changes from the previous ...

Read More »

Java Build Tools: Ant vs. Maven vs. Gradle

In this tutorial, we will compare the Java build tools such as ant, maven and gradle. These tools can be used for unit testing and building web applications. 1. Overview We will take a look at different java build tools such as Ant, Maven and Gradle. Table Of Contents 1. Overview 2. Java Build Tools Comparison 2.1. Prerequisites 2.2. Download ...

Read More »

Java Add Newline Character Example

1. Introduction In this post, we feature a comprehensive article on Java Add Newline Character. A new line character is a character which marks the end of a text line and the beginning of a new line. According to the ASCII table, there are two control characters which represent a new line: LF – represents “NL line feed, new line”CR ...

Read More »

Java CompletableFuture Example

1. Introduction In this post, we feature a comprehensive article on Java CompletableFuture. Asynchronous operations are common in Java applications. There are lots of challenges when dealing with asynchronous operations, such as memory leaking, race condition, callback hell, disjointed error handling, etc. Java has provided the CompletableFuture<T> class to ease these challenges since version 8. It has about 50 methods ...

Read More »

Java 12 New Features Tutorial

In this tutorial, I will demonstrate how to install JDK12 and dive into several API changes with Java examples. Table Of Contents 1. Introduction 2. Technologies Used 3. Set Up 3.1 Install Oracle Open JDK 12 3.2 Install Eclipse 4.11 3.3 Maven Project 4. Changes in String 5. Changes in NumberFormat 6. Changes in Collectors 7. Support Unicode 11 8. ...

Read More »