Java Programming Tutorials

Java programming tutorials with many code examples!

Java Singleton – on demand initialization

Java Singleton – on demand initialization

On demand initialization is extension of static final implementation. It will prevent eager initialization of the singleton instance, when other fields are accessed. Also known as Bill Pugh‘s solution.

Read More

Share with the World!

Java Singleton – static final implementation

Java Singleton – static final implementation

It is the simplest and most common implementation of Singleton Design Pattern in Java. In this post we’ll show how to implement it correctly and explain why it works.

Read More

Share with the World!

Java CyclicBarrier – game simulation

Java CyclicBarrier is very convenient synchronization tool for writing concurrent simulations. In this post we’ll show how it works and write a game simulation.

Read More

Share with the World!

Java Reverse String in 2 ways

Java Reverse String in 2 ways

Java String doesn’t have reverse method, so it may not be immediately apparent how to reverse a string in Java. Here are two ways do do it.

Read More

Share with the World!

Insertion Sort in Java

Insertion Sort in Java

Insertion Sort is another simple to understand and implement algorithm. Unlike Selection Sort it can work faster with certain data.

Read More

Share with the World!

Selection Sort in Java

Selection Sort in Java

Selection Sort is one of many sorting algorithms, but unlike a few others it is easy to understand and implement as we’re going to show here!

Read More

Share with the World!

Java Util Optional map(Function)

java.util.Optional.map(Function)

The method Optional.map(Function) applies the given function to the optional value if it is present and returns an optional with the result or empty optional.

Read More

Share with the World!