Java

“Core Java” is Sun’s term, used to refer to Java SE, the standard edition and a set of related technologies, like the Java VM, CORBA, etc. This is mostly to differentiate from others like Java ME or Java EE. “Core Java” is Oracle’s definition and refers to subset of Java SE technologies.

The Core Java technologies and application programming interfaces (APIs) are the foundation of the Java Platform, Standard Edition (Java SE). They are used in all classes of Java programming, from desktop applications to Java EE applications.

Related Tags

Tutorials

Creating New Directories in Java

Learn to create a new single directory or nested directory along with parent directories in a specified path using Java IO and NIO classes.

Writing Byte[] to a File in Java

Learn to write the given byte[] into a file using different solutions. We will be using the Java NIO, Commons IO and Guava APIs that provide simple APIs for this usecase.

Java Stream Tutorials

This Java tutorial lists down the published tutorials on this blog related to Stream API, methods and its related concepts with examples.

Reading a Large File Efficiently in Java

Learn to read all lines from a large file (size in GB) in Java and avoid any performance pitfalls such as very high usage of memory or even OutOfMemoryError if the File is large enough.

Rename or Move a File or Directory in Java

Learn to rename a file or directory at a specified path or move to a new directory in Java. We will learn to use the classes from Standard IO, New IO, Guava and Commons IO.

Getting Filesystem Paths in Java

Learn the difference between path, absolute and canonical paths. Also, learn to get the path of a file in Java using standard IO and New IO classes.

Primitive Type Streams in Java

Learn to create and operate on the streams of primitive types (IntStream, LongStream and DoubleStream) in Java with examples.

Java Date Time Tutorials

The legacy Java API had been a big pain point for Java developers for quite a long time. With the release of Java 8 release (JSR-310), package java.time introduced the new immutable classes that solved the issue with the original classes. Following articles have been published to help you start with some very common …

How to Set the JVM Timezone

Learn to set the default time zone used by the JVM using an environment variable, JVM argument and TimeZone class.

Finding the Day of Week for a Date in Java

Learn to find the day of the week for a given date using the legacy Date and Calendar classes as well as the new Java 8 Date API. 1. Overview There may be a requirement to show the day of the week (Monday to Sunday) in the UI, and then …

Getting the Start and the End of a Day in Java

Learn to get the start and the end of a date using Java date API, e.g., LocalDateTime and ZonedDateTime. We may require to get this information in many cases. For example, we have to filter the events that occurred at different times in a single day based on event timestamps. …

Difference between ZonedDateTime and OffsetDateTime

Learn about ZonedDateTime and OffsetDateTime classes in Java, and what are the main differences between both classes in depth. 1. Understanding Zone Id and Zone Offsets Before jumping to the internals of the classes, let’s make sure we understand the difference between the zone identifier and zone offsets. Most programming …

Localized Date Time Formats in Java

Starting with JDK 8, we have a comprehensive date-time API containing classes such as LocalDate, LocalTime, LocalDateTime, ZonedDateTime, OffsetDateTime, and OffsetTime. These classes allow easy formatting of the date-time output via DateTimeFormatter.ofPattern(). The API also allows further customize the output based on specified Locale information to support localization and internationalization features. In …

Java 8 Date Time API

Java supports creating and modifying the date and time using primarily two packages java.time and java.util. The package java.time was part of Java 8 release (JSR-310) that introduced the new immutable classes solving the shortcomings of the legacy java.util.Date and java.util.Calendar classes. 1. Legacy Date Time API (Prior to Java …

Java Array

Arrays in Java, conceptually, are no different than in other programming languages. The java.util.Arrays class provides many useful static methods to work with arrays and perform common operations on them. 1. Array Basics 2. Array Operations 3. Searching and Sorting 4. Conversions 5. Advance Topics Happy Learning !! Sourcecode on …

Java ArrayStoreException and How to resolve it?

Learn why we get the ArrayStoreException while working with arrays in Java and how to identify the root cause and fix this error. 1. Root Cause of ArrayStoreException Java arrays are covariant and support the subtyping rules of Java, an array of type T[] may contain elements of type T …

Calculate Sum and Average of Array Items

Learn to find the sum and average of the numbers stored in an array. We will be using the Java Stream API and simple for loop to find these values. Note that the numbers in Java are represented with 8 primitives i.e. short, char, byte, boolean, int, float, long and …

Convert a List to Array and back in Java

Learn to convert a list to an array in Java and also convert a given array to a list. We will learn the conversions using the core Java APIs. 1. Converting List to Array We can use the following two approaches to convert a given list to an array. 1.1. …

Convert between Stream and Array in Java

Learn to convert a stream to an array and vice versa in Java. We will learn to convert for the primitives as well as the Object types. Note that Java Stream API provides the following specialized classes for the stream of primitives. These classes support many useful sequential and parallel …

Removing Items from an Array in Java

Learn to remove the array items in Java by the index positions as well as by the item values. Note that theoretically, we can remove an array item in two ways: Create a new array and copy all items from the original array, except the index or item to be …

Convert Between Array of Primitives and Array of Objects

Learn to convert an array of primitives (int, long or double) to an array of objects (Integer, Double or Long), and vice versa. For example, we will convert int[] to Integer[] and then convert back the Integer[] to int[]. Note that all the techniques follow the same logic for the …

How to Split an Array in Java

Learn to split an array in Java using different ways. We will learn to split the array into equal parts, at the specified index and of equal lengths. 1. Arrays.copyOfRange() API The copyOfRange() creates a new array of the same type as the original array, and contains the items of …

How to Concatenate Two Arrays in Java

Learn to concatenate two primitive arrays or objects arrays to create a new array consisting of the items from both arrays. We will learn to merge array items using simple for-loop, stream API and other utility classes. Note that no matter which technique we use for merging the arrays, it …

Checking if Two Arrays are Equal in Java

Learn to compare two arrays using different techniques in Java. We will learn the array comparison from using simple for loops to inbuilt Java APIs. 1. How is the Arrays Comparison Done? In Java or any other programming language, the basics behind comparing two arrays are the same. Two arrays …

Checking if an Array is Sorted in Java

Learn to check if a given array is already sorted for a defined sorting order i.e. ascending, descending or the custom order. 1. Overview An array is considered sorted if every item in the array is greater or lesser than its predecessor based on the sorting order of the array. …

Find Top N Items from an Array in Java

Learn to find the top N items in a given array in Java. Note that we should be very clear about the meaning of top N items. The suggested solution may need minor changes based on our interpretation and requirement. For example, in this tutorial, top N items mean the …

Find Max and Min in an Array in Java

Learn to find the smallest and the largest item in an array in Java. We will discuss different approaches from simple iterations to the Stream APIs. In the given examples, we are taking an array of int values. We can apply all the given solutions to an array of objects …

Resizing Arrays in Java

Arrays are fixed-size data structures and array sizes can not be changed once they have been initialized. However, in cases where array size needs to be changed, we have to follow one of the given approaches in this tutorial. 1. Using java.util.Arrays.copyOf() The copyOf(originalArray, newLength) method takes an array and …

Reverse an Array in Java

Learn how to reverse or invert an array in Java. A reversed array is of equal size to the original array and contains the same items but in the reverse order. 1. Collections.reverse() API The easiest way to reverse the array is to use the existing APIs built for this …

How to Declare and Initialize an Array in Java

Learn to declare and initialize arrays using different techniques and their differences. Apart from directly accessing the arrays, we will also be using the java.util.Arrays and Stream API that provides several useful methods to work with arrays in Java. Note that an array is a contiguous block of memory so …

Java Tutorial

Java is one of the most popular programming languages for developing all kinds of desktop applications, web applications and mobile apps. The following articles will help you quickly become familiar with Java language and move towards more complex concepts such as API and cloud development. 1. Java Language Basics Start …

How to Sort an Array, List, Map or Stream in Java

Learn to sort a Java Set, List and Map of primitive types and custom objects using Comparator, Comparable and new lambda expressions. We will learn to sort in ascending and descending order as well. 1. Sorting a List of Objects To sort a list of objects, we have two popular …

Java Fluent Logging with Flogger

Flogger, developed, used and recommended by Google, is a fluent style logging API for Java. Apart from fluency, flogger offers many more other features than existing logging frameworks that we will learn in this tutorial. 1. Flogger Dependencies Flogger, similar to SLF4J, acts as an abstraction and uses the underlying …

Logback XMLLayout

Logback XMLLayout outputs events into XML format that is log4j.dtd compliant (instead of an W3C XML Schema). The generated XML logs can be viewed using the opensource Log viewer tools such as Apache Chainsaw and vigilog. 1. XMLLayout Sample Configuration The given configuration logs into the rolling files using the …

Java Stream – Sort with Null Values

Learn to sort a Java List or Stream with Comparator‘s nullsFirst() and nullsLast() methods. The Stream may contain null values, or the custom objects may have null field values. Failing to handle the null values during comparison will cause NullPointerException in runtime. 1. Introduction In this tutorial, we will learn …

Java 17 New Features (with Examples)

Java 17 was released on September 14, 2021. Java 17 is an LTS (Long Term Support) release, like Java 11 and Java 8. Oracle will support it for bug fixes, patches and performance enhancements for the next few years. Spring 6 and Spring boot 3 will have first-class support for …

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.