CORE API / CATATAN</>↗Core API28 Jun 2010
The code snippet shows you how to create and instance of Hashtable that stores Integer values using a String keys. After that we iterate the elements of the Hashtable using the Enumeration interface. package org.kodejava.util; import java.util.Enumeration; import java.util.Hashtable; public class HashtableDemo { public static void main(String[] args) { // Creates an instance of Hashtable […]
CORE API / CATATAN</>↗Core API23 Jun 2010
This example show you how to create a Deque using the ArrayDeque implementation. The ArrayDeque stores its elements using an array. If the number of elements exceeds the space in the array, a new array will be allocated, and all elements moved the new allocated array. In the code below we initiate the size of […]
CORE API / CATATAN</>↗Core API22 Jun 2010
The following code snippets show you how to iterate and read java.util.Vector elements using the java.util.Enumeration. package org.kodejava.util; import java.util.Enumeration; import java.util.Vector; public class VectorEnumeration { public static void main(String[] args) { Vector<String> data = new Vector<>(); data.add("one"); data.add("two"); data.add("three"); StringBuilder sb = new StringBuilder("Data: "); // Iterates vector object to read it elements for […]
CORE API / CATATAN</>↗Core API19 Jun 2010
This example demonstrates the use of Deque.removeFirstOccurrence() method call to remove the first occurrences of an element in the Deque object and Deque.removeLastOccurrence() method call to remove the last occurrences of an element in the Deque object. package org.kodejava.util; import java.util.Deque; import java.util.Iterator; import java.util.LinkedList; public class DequeRemoveDemo { public static void main(String[] args) { […]
CORE API / CATATAN</>↗Core API17 Jun 2010
This example show you how to create a LIFO (Last In First Out) Deque. We call the Deque.peekLast() method to get the last element from the Deque, poll the last element and repeat until all the elements read. package org.kodejava.util; import java.util.Deque; import java.util.LinkedList; public class DequeLifoDemo { public static void main(String[] args) { // […]
CORE API / CATATAN</>↗Core API16 Jun 2010
package org.kodejava.util; import java.util.TimeZone; public class HostDefaultTimeZone { public static void main(String[] args) { // Gets the default TimeZone ID for this host String id = TimeZone.getDefault().getID(); System.out.println("Default Time Zone ID: " + id); } } The default timezone id for this host is: Default Time Zone ID: Asia/Shanghai