SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

BASIC / NOTES</>↗
Basic21 Aug 2011

How do I use try-with-resources statement?

The try-with-resources statement is introduced in the Java 7. With this new statement we can simplify resource management in our program, also known as ARM (Automatic Resource Management). This statement is a try statement that declares one or more resources. After the program finish with the resource, it must be closed. The try-with-resources ensures that […]

Wayan · 1 min read
BASIC / NOTES</>↗
Basic15 Aug 2011

How do I use string in switch statement?

Starting from Java 7 release you can now use a String in the switch statement. On the previous version we can only use constants type of byte, char, short, int (and their corresponding reference / wrapper type) or enum constants in the switch statement. The code below give you a simple example on how the […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API15 Aug 2011

How do I use multi-catch statement?

The multi-catch is a language enhancement feature introduces in the Java 7. This allows us to use a single catch block to handle multiple exceptions. Each exception is separated by the pipe symbol (|). Using the multi-catch simplify our exception handling and also reduce code duplicates in the catch block. Let’s see an example below: […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API15 Aug 2011

How do I read all lines from a file?

The java.nio.file.Files.readAllLines() method read all lines from a file. This method ensures that the file is closed when all bytes have been read or an I/O error, or other runtime exception, is thrown. Bytes from the file are decoded into characters using the specified charset. Note that this method is intended for simple cases where […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API14 Aug 2011

How do I count active thread in a thread group?

This example describe how to get the number of active threads in this thread group. The result might not reflect concurrent activity, and might be affected by the presence of certain system threads. Due to the inherently imprecise nature of the result, it is recommended that this method only be used for informational purposes. package […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API14 Aug 2011

How do I get number of active thread in current thread?

In this example you’ll see how to obtain the number of active thread in the current thread. You can use the Thread.activeCount() method to get this information. package org.kodejava.lang; public class CountActiveThread { public static void main(String[] args) { Thread t = new Thread(() -> System.out.println("Hello…")); t.start(); // Get the number of active threads in […]

Wayan · 1 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.