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

Java String Constant Pool

Learn about String class in Java, the motivation behind making it immutable, and the idea of a String constant pool. We will see how memory is manipulated when we create String instances via String literals or String constructors. Finally, we will go through the main advantages and disadvantages caused by …

Java Enum with Multiple Values

Learn to create Java enum where each enum constant may contain multiple values. We may use any of the values of the enum constant in our application code, and we should be able to get the enum constant from any of the values assigned to it. 1. How to Create …

Java Program to Check Weekend

Learn to check if a given Date is a weekend in Java. We will learn to check using java.util.Date as well as Java 8 java.time.LocalDate classes. In the given examples, we are assuming that a weekend is either Saturday or Sunday. The rest five days of the week are weekdays. …

Java FileWriter

The Java FileWriter class is for writing the text to the character-based files using a default buffer size. It uses character encoding default to the platform, if not provided otherwise. FileWriter is usually wrapped by higher-level Writer types, such as BufferedWriter or PrintWriter. FileWriter provides better performance and higher-level, more …

Java InputStreamReader

The Java InputStreamReader class is often used to read characters from files (or network connections) where the bytes represents text. In this Java tutorial, we will learn about InputStreamReader class, its creation and initialization, and its methods which help in reading the data from the source. 1. InputStreamReader class It …

Guide to Java StringReader

Java StringReader represents a character stream whose source is a string. Use it to pass a string to a method that accepts a Reader Type.

Java FileReader

Java FileReader class can be used to read data (stream of characters) from files. In this tutorial, we will learn about FileReader class, its constructors, methods and usages with the help of examples. 1. Introduction The FileReader class is: 2. Creating FileReader To use the FileReader in the application, we …

How to Install Java on Windows 64 bit Machine

Learn to install Java on 64-bit Windows machines in this step-by-step guide. 1. Navigate to the Oracle Java Download Page Navigate to the Java download page for the latest Java release. Click on the link “JDK Download”. 2. Download the zip or Exe Package Here you have two choices: 2.1. …

Java Record Type

Java records were introduced as a preview feature in Java 14 [JEP-359] and finalized in Java 16 [JEP-395]. A record, in Java, acts as a transparent carrier for immutable data. Conceptually, records can be thought of as tuples that are already available via 3rd party libraries. Though, records are built-in type …

The yield keyword in Java

Introduced in Java 13 as part of the enhancements in Project Amber, the ‘yield‘ keyword aims to simplify code, making switch expressions more concise and expressive. Let us learn about ‘yield‘ keyword, its purpose, syntax, and see some practical examples. 1. The ‘yield‘ Keyword The ‘yield’ keyword enhances the switch …

Java Period – Difference between Dates in Days, Months and Years

Learn to create and use the Period class that was introduced as part of the new Date Time API in Java 8. The Period class represents the period of time in date-based values such as days, months, years, weeks, or years in the ISO-8601 calendar system such as “1 year …

Java TemporalAdjusters – Calculate Recurring Dates

Learn to use Java TemporalAdjusters that help with complex date-time calculations such as calculating recurring meeting dates, processing weekly reports, sending automated monthly report outs, etc. 1. Overview In the new Java Date API, the Temporal interface represents a date, time, or a combination of both. For example, LocalDate, LocalDateTime …

Format a Date to String in Java

Learn to format a given date to a specified formatted string in Java. We will learn to use inbuilt patterns and custom patterns with DateTimeFormatter and SimpleDateFormat. 1. Formatting with DateTimeFormatter [Java 8] Since Java 8, We can use DateTimeFormatter for all types of date and time related formatting tasks. …

Check if a Date is Valid in Java

Learn to validate whether a given string contains a date value in Java using various date validation techniques available in Java 8.

Getting All Dates Between Two Dates in Java

Learn to get all the dates between the two given dates. We will see the solutions in Java 7, Java 8, and Java 9. 1. LocalDate.datesUntil() (since Java 9) LocalDate‘s datesUntil() method returns a sequential ordered stream of all dates between two given dates. The returned stream starts from startDate …

Number of Days between Two Dates in Java

In Java, we can use the ChronoUnit and LocalDate.until() methods to calculate the number of days between two given dates. Other solutions exist, but these are the simplest and do not require importing an additional library. 1. Using ChronoUnit to Find the Number of Days between Two Dates Using ChronoUnit.DAYS.between() …

Find all Business Days between Two Dates

Learn to find all business days between two given dates in Java. The business days are considered all weekdays, excluding all holidays falling on weekdays. Once we have a List of business dates, we can use the list.size() API to get the total count of business days. The given examples …

Add or Subtract Business Days in Java

Learn to add or subtract a given number of business days to new date times classes in Java such as LocalDate, LocalDateTime and ZonedDateTime. The given example takes the holidays list as well into consideration. Read More: Add or Subtract Days to/from Date 1. Adding Business Days It uses two …

Java DayOfWeek

Learn to determine which day of the week is a given date in Java. The weekdays are considered all 7 days from Sunday, Monday till Saturday. 1. DayOfWeek Enum DayOfWeek is an enum representing the seven days of the week – Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday. 2. …

Java TemporalQuery

TemporalQuery is a standard way of querying the temporal objects (LocalDate, LocalDateTime etc) for making better business decisions. In Java 8, all major date-time classes implement Temporal and TemporalAccessor interfaces so TemporalQuery can be run against all those Java classes. 1. TemporalQuery interface In the new Java Date API, Temporal …

Calculate Next and Previous Date in Java

Java examples to get the next day or the previous day for any given day. The example uses legacy java.util.Date class as well as java.time.LocalDate class from Java 8. We can use this example code to calculate tomorrow’s and yesterday’s dates based on the date of today. 1. Using LocalDate …

Java UUID Generator Example

Learn what is UUID and it’s versions and variants. Learn to generate UUID in Java using UUID.randomUUID() API. Also learn to generate version 5 UUID in Java. 1. What is UUID? UUID (Universally Unique IDentifier), also known as GUID (Globally Unique IDentifier) is 128 bits long identifier that is unique …

Pairs in Java

Learn to work with key value pairs in Java using Pair classes e.g. javafx.util.Pair, ImmutablePair, MmutablePair (common langs) and io.vavr.Tuple2 class. Read More : Tuples in Java 1. Why we need pairs? A pair provide a convenient way of associating a simple key to value. In Java, maps are used …

Parse a String to UTC Date Time

Learn to convert a string to date time instance classes e.g. ZonedDateTime or OffsetDateTime classes, using DateTimeFormatter class in Java. 1. Instant, OffsetDateTime and ZonedDateTime Classes In Java 8, OffsetDateTime and ZonedDateTime – both store an instant on the universal timeline to nanosecond precision. OffsetDateTime adds to the instant the …

Regex – Match Any Character(s)

In regex, we can match any character using period “.” character. To match only a given set of characters, we should use character classes.

Regex – Match Start or End of String (Line Anchors)

Regular expressions, commonly referred to as regex, are powerful tools for pattern matching and manipulation of text. The regex patterns enable developers to perform intricate string searches, substitutions, and validations. Among the plethora of regex features, line anchors are the key components for precisely identifying the beginning or end of …

How to Shutdown a Java ExecutorService

Learn ExecutorService shutdown(), shutdownNow() and awaitTermination​() APIs and how to use them correctly to shutdown executor under different conditions,

Java ExecutorService invokeAll()

Learn to run multiple Callable tasks with ExecutorService.invokeAll(tasks) API and processing all the results returned from tasks in form of Future class instances in this ExecutorService Callable example.

ExecutorService invokeAny()

Learn to use ExecutorService invokeAny() method where we execute multiple tasks at same time, but we make a decision asap any one of tasks is completed.

Executor RejectedExecutionHandler

Learn to handle tasks which are submitted to Executor and are rejected because the executor has been shutdown for any reason using RejectedExecutionHandler. 1. When tasks get rejected Remember when we finish the execution of an executor, we use the shutdown() method. The executor waits for the completion of tasks …

Guide to ExecutorService in Java

Learn to use Java ExecutorService to execute a Runnable or Callable class in an asynchronous way. Also learn the various best practices to utilize it in most efficient manner in any Java application.

Compare Two LocalDateTime Instances

Learn to compare two LocalDateTime instances to find out which date represents an older timestamp in comparison to other timestamp. LocalDateTime class is part of java.time package added in Java 8.

Compare Two LocalDate Instances in Java

Learn to compare two LocalDate instances to find out which date represents an older date in comparison to second date. LocalDate class is part of java.time package added in Java 8.

Guide to AtomicInteger in Java

The AtomicInteger class protects an underlying int value by providing methods that perform atomic operations on the value. It shall not be used as a replacement for an Integer class.

How to Format LocalDate in Java

Java examples to format LocalDate to String using inbuilt and custom patterns using FormatType and format(formatter) API.

Java Check Leap Year Examples

Java programs to find if a given year is a leap year using new Java 8 APIs (LocalDate and Year), legacy Java 7 GregorianCalendar, and custom code.

Compare Two ZonedDateTime Instances

Learn to compare two instances of ZonedDateTime either in the same timezone or in different timezones in Java 8. 2. Comparing at Same Instant As we know an instance of ZonedDateTime is a point in the universal timeline with an offset. So to compare two such instances, logically, both instances …

Convert between LocalDate and ZonedDateTime

Learn to convert from LocalDate to ZonedDateTime and from ZonedDateTime to LocalDate in Java 8. As we know, LocalDate represents a calendar date without the time and the zone information. ZonedDateTime instance contains all three information i.e. date, time and zone. ZonedDateTime = LocalDate + time + timezone 1. LocalDate …

Parse String to ZonedDateTime in Java

Java 8 ZonedDateTime class represents an instant in the universal timeline with the timezone information. In this tutorial, we will learn to parse a string to ZonedDateTime object using its parse() method. 1. Parsing a Date Time with ZonedDateTime.parse() Java program to convert a given string into ZonedDateTime instance. After …

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.