Ultimate Guide: Java Queue, Deque, and Stack - feature image

by Sven Woltmann – April 8, 2020

Sooner or later, Java developers have to deal with the abstract data type queue, deque, and stack. This article explains the basic functionality of these data structures and gives a detailed overview of all implementations available in the JDK. Numerous code examples should make it easier for you to understand. In detail, the article answers

Read More »
How to switch Java versions in Windows - feature image

by Sven Woltmann – March 17, 2020

As a Java programmer, I work on various projects based on different Java versions, especially since the transition to the six-month release cycle. From time to time, I also have a piece of Java code that I want to try out on different Java versions – on the command line without having to click through

Read More »
Java - How to Hack Integer and String With Deep Reflection - feature image

by Sven Woltmann – March 11, 2020

I am currently reading the book “The Pragmatic Programmer” by Andrew Hunt and David Thomas. In this book, the authors give the following task: Which of these “impossible” things can happen? […]3. In C++: a = 2; b = 3; if (a + b != 5) exit(1); […] One of the correct answers is 3.

Read More »
ByteBuffer How to use flip() and compact() - Feature image

by Sven Woltmann – February 26, 2020

In this article, I show you, using an example, how the Java ByteBuffer works, and what precisely the Methoden flip() and compact() do. The article answers the following questions: What is a ByteBuffer, and what do you need it for? How do you create a ByteBuffer? What do the values position, limit, and capacity mean?

Read More »
FileChannel, ByteBuffer, Memory-mapped I/O, Locks - Feature image

by Sven Woltmann – February 26, 2020

The previous five parts of this article series covered reading and writing files, directory and file path construction, directory and file operations, and writing and reading structured data. In today’s part, I explain the NIO classes FileChannel and ByteBuffer introduced in Java 1.4 with JSR 51 (“New I/O APIs for the JavaTM Platform”). Moreover, I

Read More »
Java files - Basics: writing files - Feature image

by Sven Woltmann – December 4, 2019

After the first part of the series was about reading files in Java, this second part introduces the corresponding methods for writing small and large files. The article addresses the following questions in detail: What is the easiest way to write a string or a list of strings to a text file? How to write

Read More »
Java files - Basics: reading files - Feature image

by Sven Woltmann – November 21, 2019

The packages java.io and java.nio.file contain numerous classes for reading and writing files in Java. Since the introduction of the Java NIO.2 (New I/O) File API, it is easy to get lost – not only as a beginner. Since then, you can perform many file operations in several ways. This article series starts by introducing

Read More »