CORE API / CATATAN</>↗Core API19 Mei 2007
This example demonstrate you how to use the HashMap class to store values in a key-value structure. In this example we store a map of error codes with their corresponding description. To store a value into the map we use the put(key, value) method and to get it back we use the get(key) method. And […]
CORE API / CATATAN</>↗Core API16 Mei 2007
Using java.util.Random class we can create random data such as boolean, integer, floats, double. First you’ll need to create an instance of the Random class. This class has some next***() methods that can randomly create the data. package org.kodejava.util; import java.util.Arrays; import java.util.Random; public class RandomDemo { public static void main(String[] args) { Random r […]
CORE API / CATATAN</>↗Core API11 Mei 2007
In the other examples on this website you might have seen how to reverse a string using StringBuffer, StringUtils from Apache Commons Lang library or using the CharacterIterator. In this example you’ll see another way that you can use to reverse a string by word. Here we use the StringTokenizer and the Stack class. package […]
CORE API / CATATAN</>↗Core API07 Mei 2007
Varargs can be seen as a simplification of array when we need to pass a multiple value as a method parameter. Varargs itself is an array that automatically created, for these reason you will be enabled to do things you can do with array to varargs. In the example below you can see the messages […]
CORE API / CATATAN</>↗Core API02 Mei 2007
The trim() method of a String class removes both leading and trailing white space from a string. In this example we use a regular expression to remove only the trailing white spaces from a string. package org.kodejava.lang; public class TrailingSpace { public static void main(String[] args) { String text = " tattarrattat "; System.out.println("Original = […]
CORE API / CATATAN</>↗Core API27 Apr 2007
The trim() method of a String class removes both leading and trailing white space from a string. In this example we use a regular expression to remove only the leading white spaces from a string. package org.kodejava.lang; public class LeadingSpace { public static void main(String[] args) { String text = " tattarrattat "; System.out.println("Original = […]