CORE API / CATATAN</>↗Core API23 Jul 2007
In the previous example, How do I read user input from console using Scanner class?, we use the java.util.Scanner class to read user input. In this example we use another new class introduced in the Java 1.6, the java.io.Console class. The Console class provide methods like readLine() and readPassword(). The readPassword() method can be used […]
CORE API / CATATAN</>↗Core API22 Jul 2007
In JDK 1.5 a java.util.Scanner class was introduced to handle user input in console application. This class enable us to read string, integer, long, etc. package org.kodejava.util; import java.util.Scanner; public class ScannerDemo { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // Read string input for username System.out.print("Username: "); String username = […]
CORE API / CATATAN</>↗Core API19 Jul 2007
Creating an application for users in different regions can be hard in terms of the message format for the local region. Java provide a ResourceBundle class that help internationalize our application. To create resources for i18n (there are 18 letters between the first i and the final n) we need to create a file for […]
APACHE COMMONS / CATATAN</>↗Apache Commons14 Jul 2007
In the code example below we demonstrate the ArrayUtils.toPrimitive() method to convert an array of Integer object to an array of its primitive type. Besides converting an array of Integer objects, this method is overloaded to accept other types of object’s array. package org.kodejava.commons.lang; import org.apache.commons.lang3.ArrayUtils; public class ArrayObjectToPrimitiveDemo { public static void main(String[] args) […]
APACHE COMMONS / CATATAN</>↗Apache Commons11 Jul 2007
This example uses the Apache Commons Lang’s ArrayUtils.toMap() method to convert a two-dimensional array into a Map object. To convert a two-dimensional array into a Map object, each element of the two-dimensional array must be an array with at least two elements where the first element will be the key and the second element will […]
APACHE COMMONS / CATATAN</>↗Apache Commons09 Jul 2007
In this example we are going to use the ArraysUtils helper class from the Apache Commons Lang library to reverse the order of array elements. The method to reverse the order of array elements is ArrayUtils.reverse() method. The ArrayUtils.reverse() method is overloaded, so we can reverse another type of array such as java.lang.Object, long, int, […]