CORE API / NOTES</>↗Core API30 May 2007
You want to create a program that read a webpage content of a website page. The example below use the URL class to create a connection to the website. You create a new URL object and pass the URL information of a page. After the object created you can open a stream connection using the […]
APPLET / NOTES</>↗Applet26 May 2007
In this applet example you’ll see how to display a message in browser status bar. To make the example a bit more interesting we’ll display the current time as the message. The time will be updated every on second during the lifetime of the applet. package org.kodejava.applet; import java.applet.Applet; import java.awt.Graphics; import java.text.DateFormat; import java.text.SimpleDateFormat; […]
CORE API / NOTES</>↗Core API23 May 2007
This example demonstrates you how to remove duplicate elements from an array using the help of java.util.HashSet class. package org.kodejava.util; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; public class ArrayRemoveDuplicate { public static void main(String[] args) { // A string array with duplicate values. String[] data = {"A", "C", "B", "D", "A", "B", "E", […]
CORE API / NOTES</>↗Core API22 May 2007
package org.kodejava.util; import java.util.*; public class ArrayToSetExample { public static void main(String[] args) { Integer[] numbers = {7, 7, 8, 9, 10, 8, 8, 9, 6, 5, 4}; // To convert an array into a java.util.Set firstly we need to convert the // array into a java.util.List using the Arrays.asList() method. With the // List […]
CORE API / NOTES</>↗Core API19 May 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 / NOTES</>↗Core API16 May 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 […]