Home » Core Java (page 3)

Core Java

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 »

SQL Data Types Tutorial

1. Introduction SQL is the language used to communicate with Relational Databases such as MySQL, Oracle, MS SQL Server, PostgreSQL, etc. In this post, we will examine the various SQL Data Types and provide examples for MySQL, which is the most widely used open-source database. This post requires some knowledge in SQL and a tutorial for a complete understanding of ...

Read More »

Java sort ArrayList Example

1. Introduction In this article we are going to look at the ArrayList class in Java. It is part of the java.util package. First though, in order to better understand the ArrayList class, we need to understand what an array is and how the two classes differ. 2. What is an Array? Techterms.com offers a succinct definition of an array, ...

Read More »

Java Classes and Objects Tutorial

Java language has object-oriented features to create classes and objects. In this tutorial, how to develop Java classes and instantiate objects from java classes is discussed in detail. Table Of Contents 1. Overview 2. Java Classes and Objects Tutorial 2.1. Prerequisites 2.2. Download 2.3. Setup 2.4. Java Classes and Objects 2.5. BestPractices 2.6. Error Handling 2.7. Code Conventions 3. Download ...

Read More »

Java round double value to 2 decimal places Example

1. Introduction A double variable is used to hold a floating point value, such as 12.578. A decimal place is the position of a digit to the right of a decimal point. The 12.578 with 2 decimal places is represented as 12.57. Java has provided PrintStream, String.format, Formatter, NumberFormat, DecimalFormat, and BigDecimal to format and round a number based on ...

Read More »

Java Immutable Objects Example

1. Introduction In programming, an object is considered immutable if its state cannot change after it is created. Java not only supports immutable objects but as a best practice, they should be widely used. In this post, we will take a look at how to create immutable objects, their use cases and some examples of immutable Classes. The technologies that ...

Read More »

Java Thread Example

1. Introduction Every Java program has at least one thread, the main thread. This is spun up by the Java Virtual Machine (JVM) when you run your code. Java is multithreaded which means it can utilise multiple threads concurrently. Thankfully, Java makes it easy to work with threads and multithreading. However as developers or programmers we need to take threading ...

Read More »