CORE API / CATATAN</>↗Core API27 Feb 2013
The java.nio.Path provides some methods to obtain information about the Path. For example, you can get information about the file name, the parent and the root path. For these you can call the getFileName(), getParent() and getRoot() method respectively. You can also get the number of elements that make up this Path using the getNameCount() […]
CORE API / CATATAN</>↗Core API26 Feb 2013
The following code snippet show you how to create a Path. A Path (java.nio.Path) in an interface that represent a location in a file system, such as C:/Windows/System32 or /usr/bin. To create a Path we can use the java.nio.Paths.get(String first, String… more) methods. Below you can see how to create a Path by passing only […]
BASIC / CATATAN</>↗Basic23 Feb 2013
Writing a long sequence of numbers in a code is a hard stuff to read. In the new feature introduced by JDK 7 we are now allowed to write numeric literals using the underscore character to break the numbers to make it easier to read. You can see how to use underscore in numeric literals […]
BASIC / CATATAN</>↗Basic21 Feb 2013
The JDK 7 add a small feature to work with a binary number. In the previous JDK we have to use the Integer.parseInt() method if we need to work with other base number. But with this new feature introduced in the Project Coin we can simplify the code when we work with the binary number. […]
BASIC / CATATAN</>↗Basic09 Des 2012
The following code snippet will show you how to pick a random value from an enum. First we’ll create an enum called BaseColor which will have three valid value. These values are Red, Green and Blue. To allow us to get random value of this BaseColor enum we define a getRandomColor() method in the enum. […]
BASIC / CATATAN</>↗Basic09 Des 2012
In Java 7 a new feature called diamond syntax or diamond operator was introduced. This diamond syntax <> simplify how we instantiate generic type variables. In the previous version of Java when declaring and instantiating generic types we’ll do it like the snippet below: List<String> names = new ArrayList<String>(); Map<String, List<Integer>> map = new HashMap<String, […]