BASIC / NOTES</>↗Basic21 Aug 2011
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 […]
BASIC / NOTES</>↗Basic15 Aug 2011
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 […]
CORE API / NOTES</>↗Core API15 Aug 2011
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: […]
CORE API / NOTES</>↗Core API15 Aug 2011
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 […]
CORE API / NOTES</>↗Core API14 Aug 2011
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 […]
CORE API / NOTES</>↗Core API14 Aug 2011
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 […]