Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners java program(Hash Table)

Have Programming Question? Ask it here!
 
 
 


Manish
java program(Hash Table)
1 Answer(s)      5 years and 9 months ago
Posted in : Java Beginners



Advertisement
View Answers

December 4, 2008 at 11:19 PM


Hi friend,

Code to solve the problem :

import java.util.*;

public class HashTable {

public static void main(String args[]) {
Hashtable table = new Hashtable();

//Put value into the table
table.put("Delhi", "India1");
table.put("Mumbai", "India2");
table.put("Kolkata", "India3");
table.put("Cheenai", "India4");
if(args.length>0)
{
String keyCity = args[0];
if(table.get(keyCity)!=null)
{
System.out.println("Country is :" + table.get(keyCity) );
}
else
{
System.out.println("City Not Found");
}
}
else
{
System.out.println("Please enter City");
}

}
}

Thanks


Related Tutorials/Questions & Answers:
java program(Hash Table) - Java Beginners
java program(Hash Table)  Store the names of 10 major cities and the names of corresponding countries in a hash table. Accept the name of a city... argument or specifies a city that is not in the hash table.  Hi friend
Java Hash table
Java Hash table   Hi I have to create code to allow the insertion of a sequence of numbers into a hash table,using a fixed size hash table. Then i... of numbers; insert these into the hash table. Can anyone give me any help
Advertisements
Hash Table for maintaining popup menus in Java
of maintaining popup menus through hash table in your Java program. This section... Hash Table for maintaining popup menus in Java  ... to create and maintain popup menus in Java. All the elements listed in the hash
Partial Search from Hash Table in Java
string in the Hash Table through the Java program and get these string easily. Here... Partial Search from Hash Table in Java   ... to put some string in the Hash Table of Java and get it for searching. This is done
Simple Hash Table implementation in Java
Simple Hash Table implementation in Java       This section describes the complete Hash Table... in the hash table. Here is the code of the program
Thread Access through the Hash Table in Java
Thread Access through the Hash Table in Java  ... is accessed by using the hash table in Java.      Here is the code of the program:        
Example to show Hash table exception in java
Example to show Hash table exception in java... of using exception class in java. This tutorial describes  the way to handle Hash table exceptions appropriately in your programs and designs. The steps
Hash table
Hash table  Hi guys.. I have question about hash table How to implement a hash table of English words? with these methods ï??· A method put(s...() which returns the number of strings in the table. ï??· A hash method
Writing and reading from/to a serialized file through Hash Table in Java
Writing and reading from/to a serialized file through Hash Table in Java... value in a hash table in the program.  Here is the code of the program... illustrates you how to read and write from/to a serialized file through the hash table
Creating a Hash Table
Creating a Hash Table : Java Util   ... table. What is the hash table and how to create that? Hash Table holds... for several values. Hash Table is created using an algorithm (hashing function
hash function for java strings
hash function for java strings  hash function for java strings   int hash=7; for (int i=0; i < strlen; i++) { hash = hash*31+charAt(i
Decreasing process time by caching through the Hash Table in Java
Decreasing process time by caching through the Hash Table in Java... by your java program. You can easily improve the process completion time... class, which returns the value existed in the hash table corresponding
java code to compare two hash map objects
java code to compare two hash map objects  java code to compare two hash map objects
Hash value is not same - Java Beginners
Hash value is not same  Hi, I've two Excel files with same data.... I've generated one way hash using SHA-1 algorithm. But the hash value of Excel 2003 files is not same as the hash value of Excel 2007 file. What might
java program for
java program for   java program for printing documents,images and cards
Java Program
Java Program  A Java Program that print the data on the printer but buttons not to be printed
program for Hashmaps - Java Beginners
a hash table as the underlying data structure to represent a set. A LinkedHashSet...program for Hashmaps  I need a program that illustrates the concept...[] args) { HashMap hash = new HashMap(); hash.put("Amardeep", new Double
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
One way hash in Java - Java Beginners
One way hash in Java  Hi, What is one way hashing. How to implement it in Java. I've to compare the contents of two files by generating their hash value in Java. Please give some examples. Thank You,  Hi Friend
java program
java program  write a program to print 1234 567 89 10
java program
java program  Write a java program to do matrix addition operation On two given matrices
java program
java program  Write a java program to find the number of Positive numbers in m* n matrix
java program
java program  Write a program to create an applet and display The message "welcome to java
java program
java program  java program to implement the reflection of a particular class details like constructor,methods and fields with its modifiers
Java Program
Java Program  java program to insert row in excel sheet after identifying an object
java program
java program  write a java program to display array list and calculate the average of given array
java program
java program  write a java program to display array list and calculate the average of given array
java program
java program  write java program for constructor,overriding,overriding,exception handling
java program
java program  how to write an addition program in java without using arithematic operator
java program
java program  Write a program to demonstrate the concept of various possible exceptions arising in a Java Program and the ways to handle them.  ... in Java
Usage of Hash Code - Java Interview Questions
Usage of Hash Code  Dear sir, What is Hashcode in Java and What is its usage? Thanks and Regards M.KehtraBalan  Hi Friend, A hashCode is a way of computing a small (32-bit) numeric key from a long
java program
java program  write a java program to compute area of a circle.square,rectangle.triangle,volume of a sphere ,cylinder and perimeter of cube using method over riding
java program
java program  write a java program to compute area of a circle.square,rectangle.triangle,volume of a sphere ,cylinder and perimeter of cube using method over riding
java program
java program  write a program to create text area and display the various mouse handling events
java program
java program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
java program
java program  Problem 2 Note:Use prompt command to input values and use document.write command to display the output. Write a JavaScript program... and display the Point Equivalent based on the table below. Indicate also the remarks
java program
java program  Problem 2 Note:Use prompt command to input values and use document.write command to display the output. Write a JavaScript program... and display the Point Equivalent based on the table below. Indicate also the remarks
Using Arraylist or Hash Map - Java Interview Questions
Using Arraylist or Hash Map  what could b the pros and cons changing between Hash Map to Array List
Java program to create a frame with 4 fields;name,sreet,city,pin;with suitable table
Java program to create a frame with 4 fields;name,sreet,city,pin;with suitable table  Java program to create a frame with 4 fields;name,street,city,pin;with suitable table. Also add a button "OK". whe it is clicked
program in java
program in java  write a reverse program in java using string buffer.the input and out put as follows. input- hi good mornig out put-ih doog ginrom
Java program
Java program  Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
java program
java program  . Develop the program calculatePipeArea. It computes the surface area of a pipe, which is an open cylinder. The program accpets three values: the pipes inner radius, its length, and the thickness of its wall
java program
java program  . Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
java program
java program  Develop the program calculatePipeArea. It computes the surface area of a pipe, which is an open cylinder. The program accpets three values: the pipes inner radius, its length, and the thickness of its wall
java program
java program   A B C D E F F E D C B A A B C D E E D C B A A B C D D C B A A B C C B A A B B A A A java program to display above triangle
java program
java program  write a program to read 10 numbers from user and store it in a array. display the maximum n minimum number in the array
java program
java program  write a program to create server and client such that server receives data from client using BuuferedReader and sends reply to client using PrintStream
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
 

 

 

DMCA.com