MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

/*
 * Output: 
    
Beijing is located in China
    
 */

import java.util.Hashtable;

public class MainClass {

    public static void main(String args[]) {

        Hashtable ht = new Hashtable();
        ht.put("Tokyo", "Japan");
        ht.put("Beijing", "China");
        ht.put("Bangkok", "Thailand");

        String city = "Beijing";
        String country = (String) ht.get(city);
        if (country != null)
            System.out.println(city + " is located in " + country);
        else
            System.out.println(city + " is not located in the hashtable");
    }
}