Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.Enumeration;
import java.util.Hashtable;

public class Main {
    static Hashtable hashtableClone(Hashtable ht) {
        if (ht == null)
            return null;

        Hashtable htresp = new Hashtable();
        Enumeration e = ht.keys();

        while (e.hasMoreElements()) {
            Object element = e.nextElement();
            htresp.put(element, ht.get(element));
        }
        return htresp;
    }

    static Hashtable hashtableClone(Hashtable ht1, Hashtable ht2) {
        if (ht1 == null && ht2 == null)
            return null;

        Hashtable htresp = new Hashtable();

        if (ht1 != null) {
            Enumeration e = ht1.keys();
            while (e.hasMoreElements()) {
                Object element = e.nextElement();
                htresp.put(element, ht1.get(element));
            }
        }
        if (ht2 != null) {
            Enumeration e = ht2.keys();
            while (e.hasMoreElements()) {
                Object element = e.nextElement();
                htresp.put(element, ht2.get(element));
            }
        }
        return htresp;
    }
}