CORE API / CATATAN</>↗Core API24 Agt 2011
You can destroy a thread group by using destroy() method of ThreadGroup class. It will cleans up the thread group and removes it from the thread group hierarchy. It’s not only destroy the thread group, but also all its subgroups. The destroy() method is of limited use: it can only be called if there are […]
JDBC / CATATAN</>↗JDBC22 Agt 2011
One thing that we need to do manually when programming using JDBC is to make sure to close all the resources that we use. All resources including the ResultSet, Statement and Connection must be closed. This will usually produce a lot of boilerplate code in our program. Starting from JDBC 4.1, which is a part […]
BASIC / CATATAN</>↗Basic21 Agt 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 / CATATAN</>↗Basic15 Agt 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 / CATATAN</>↗Core API15 Agt 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 / CATATAN</>↗Core API15 Agt 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 […]