CORE API / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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
CORE API / NOTES</>↗Core API15 Jun 2010
package org.kodejava.util; import java.util.TimeZone; public class TimeZoneByOffset { public static void main(String[] args) { // Gets the available IDs according to the given time zone // offset in milliseconds. int offset = 8 * 60 * 60 * 1000; String[] timezones = TimeZone.getAvailableIDs(offset); System.out.println("List of available IDs for GMT:+08:00"); System.out.println("===================================="); for (String id : timezones) […]
JDBC / NOTES</>↗JDBC15 Jun 2010
The examples below show you how to get the available catalog names in MySQL database. The available catalog names can be obtained from the DatabaseMetaData object by calling the getCatalogs() method. This method returns a ResultSet object. We iterate it and get the schema name by calling the getString() method and pass TABLE_CAT as the […]