Install JDK using SDKMAN

I have guided you how to install Oracle JDK on macOS by downloading the Oracle JDK installation files and installing it manually. There is another way that is much more convenient and easier which is to use the SDKMAN (Software Development Kit Manager) tool. How… Read More

Virtual thread in Java

In the tutorial Initializing and running a thread in Java, I introduced you to Java’s Thread class to create a new thread. Threads created by this Thread class are called platform threads and the number of platform threads that can be created is limited, depending… Read More

ThreadLocal in Java

The ThreadLocal class in Java is a class that allows us to store and retrieve the values of variables in the same thread. As long as it’s the same thread, you can store a value and retrieve it whenever we want. You can initialize objects… Read More

Structured Concurrency in Java

Structured Concurrency in Java is an improvement of Java from Java 19, on implementing and maintaining code related to the execution of tasks consisting of many sub-tasks handled by multi-threading. This improvement makes our code easier to read, and controls how the execution of subtasks… Read More

Get a list of files and folders in a directory with Java

Before Java 8, you can use the listFiles() method of the File class with the parameter of the directory that we want to get the list of files and directories to do this. Eg:

The return result will be a list of File objects… Read More