Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.*;

public class Main {

    public static void main(String[] args) {

        Dictionary d = new Hashtable();

        // add 2 elements
        d.put(1, "Cocoa");
        d.put(4, "from java2s.com" + "Bar");
        System.out.println("1 is " + d.get(1));
        System.out.println("4 is " + d.get(4));

        // generates a series of elements, one at a time
        for (Enumeration e = d.elements(); e.hasMoreElements();) {
            System.out.println(e.nextElement());
        }
    }
}