Hashtable java prog

Hashtable java prog

View Answers

August 27, 2009 at 5:02 PM

Hi Friend,

Try the following code:

import java.io.*;
import java.util.*;

public class displayHashTableData {

public static void main(String[] args) throws Exception {
Enumeration names;
String str;
double bal;
Hashtable<Integer,String> table = new Hashtable<Integer,String>();
table.put( new Integer(1111),"Selected");
table.put( new Integer(2222),"Not Selected");
table.put(new Integer(3333),"Not Selected");
table.put( new Integer(4444),"Selected");
System.out.println(" ");
System.out.print("Enter Ticket Number: ");
Scanner input=new Scanner(System.in);
int id = input.nextInt();
Set s =table.entrySet();
Iterator i=s.iterator();
while(i.hasNext())
{
Map.Entry map=(Map.Entry)i.next();
int key = (Integer)map.getKey();
String value=(String)map.getValue();
if(id==key){
System.out.println(value);
}
}
}
}

Hope that it will be helpful for you.
Thanks

August 27, 2009 at 9:42 PM

Thanks alot friend..Your code is too understandable and easy..thanks again









Related Tutorials/Questions & Answers:
Hashtable java prog - Java Interview Questions
Hashtable java prog  Create a hashtable with some student hall ticket numbers and their results. when we type a hallticket number,it shud display the results? please provide the detail java code for this? thanks in advance
Hashtable java prog - Java Interview Questions
Hashtable java prog  Create a Hashtable with some students hall... the results? please provide the java code detaily for this query?thanks... bal; Hashtable table = new Hashtable(); table.put( new Integer(1111),"Selected
Advertisements
Java hashtable
Java hashtable   What is hash-collision in Hashtable and how it is handled in Java
Java hashmap, hashtable
Java hashmap, hashtable  When are you using hashmap and hashtable
hashtable java swing
hashtable java swing  i m getting this warning code is here Hashtable nu=new Hashtable(); Hashtable ns=new Hashtable(); nu.put(new... mber of the raw type Hashtable plz help me
Java collection -Hashtable
Java collection -Hashtable   What is Hashtable in java collection?   Java collection -Hashtable;- The hashtable is used to store value... { public static void main(String [] args){ Map map = new Hashtable
java prog
java prog  find out a string from the collection of string in java
java prog
java prog  write a java program to accept a file name as command line argument.Append the string "file modified by program" to the end of the same file and print the contents of the modified file
java prog
java prog  Write a Java applet that inputs a person's date of birth (month, day, year): ā?¢ Informs the person if the year of birth is a prime number. ā?¢ Informs the person if the year of birth is a leap year. ā?¢ Computes
How to find hashtable size in Java?
How to find hashtable size in Java?  Hi, What is the code for Hashtable in Java? How to find hashtable size in Java? Give me the easy code. Thanks
hashtable - Java Beginners
hashtable  pls what is a hashtable in java and how can we use... to Roseindia"); Hashtable hash = new Hashtable(); hash.put("amar","amar"); hash.put...://www.roseindia.net/java/ Thanks. Amardeep
java prog que
java prog que  create a class that returns the reverse of each word in the given string. For example if we give "who are u?" as input, it should return "ohw era u
Doubts regarding Hashtable - Java Beginners
it possible to create a hashtable like this? java.util.Hashtable hashtable=new...(12,13,10,1)); since we get the key of hashtable from the database. When I tried... information, http://www.roseindia.net/java/example/java/util/ Thanks
servlet prog - Java Interview Questions
servlet to jsp? how a thread or request pass from one servlet prog to one jsp prog? is it possible of communicating from servlet to jsp prog? please explain briefly with one java code example? Thanks in advance
Java entry prog.
Java entry prog.  Dear sir I will enter the dept code, dept name and insert into dept_mast and save. Pl. Dept_mast Dept_code Char(2) Primary key (no duplicate key allowed) Dept_name Char(25
Java prog - Java Beginners
Java prog  Write a program on Java that ask the user to input: Cost of Machine, Life of Machine, Cost of capital in Percentage, in an JOption pane window and that calculates and outputs Annual Lease rent.  Hi friend i
java applet prog
java applet prog  applet to display scrolling text from right to left in an applet window using thread. text should be accepted by html parameter
Java Collection : Hashtable
Java Collection : Hashtable In this tutorial, we are going to discuss one of concept (Hashtable ) of Collection framework. Hashtable  : Hashtable.... When you increase the entries in the Hashtable, the product of the load
Java Hashtable Iterator
be traversed by the Iterator. Java Hashtable Iterator Example import java.util.*; public class hashtable { public static void main(String[] args) { Hashtable hastab = new Hashtable(); hastab.put("a", "andrews
Differences between HashMap and Hashtable?
Differences between HashMap and Hashtable?  Differences between HashMap and Hashtable
ModuleNotFoundError: No module named 'HashTable'
ModuleNotFoundError: No module named 'HashTable'  Hi, My Python... 'HashTable' How to remove the ModuleNotFoundError: No module named 'HashTable' error? Thanks   Hi, In your python environment you
NEED A PROG
NEED A PROG   whats the program to add,delete, display elements of an object using collecions. without using linked list   Hi Friend, Try the following code: import java.util.*; class CollectionExample { public
turbo C prog.
turbo C prog.  Is is possible print ASCII value of a alphabets using turbo C prog
ModuleNotFoundError: No module named 'prog'
ModuleNotFoundError: No module named 'prog'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'prog' How to remove the ModuleNotFoundError: No module named 'prog' error
The Hashtable Class
The Hashtable Class In this section, you will learn about Hashtable and its implementation with the help of example. Hashtable is integrated... it also stores key/value pair in Hashtable. But the difference is Hashtable
question "writing prog"
question "writing prog"  Hello I want helping for this question, please Write a program that reads some friendsā?? names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
please help me in these prog
please help me in these prog   create 2 jdbc programs including awt create 2 jdbc programs including swing create 2 jdbc programs including command line argument create 2 jdbc programs including io class 4 jdbc prog using
Solution to C prog
Solution to C prog   Hi, Pls any body help, why the following prog crashing while running. #include<stdio.h> #include<conio.h> int main(){ int n,*fact(int *n); printf("Enter the number:"); scanf
ModuleNotFoundError: No module named 'func_prog'
ModuleNotFoundError: No module named 'func_prog'  Hi, My Python... 'func_prog' How to remove the ModuleNotFoundError: No module named 'func_prog' error? Thanks   Hi, In your python environment you
make a prog for this query
make a prog for this query  write a program implementing interface for personal data n salary details. interface must contain abstract methods. steps for the program are 1) store the data in text file 2)display salary when emp id
turbo C prog.
turbo C prog.  Is it possible to print ASCII value A to Z with out using scan ? also give to simple example of binary search ...   #include<stdio.h> #include<conio.h> void main() { for(char c='A';c<
J2ME HashTable Example
J2ME HashTable Example       To use the HashTable, java.util.Hashtable package must be imported into the application. Generally HashTable are used to map the keys to values
Prog Error - JSP-Servlet
Prog Error   Place Ad function Browse() { Advertisement Management System Create Ad State: City: Main Category: Sub Category: Title
turbo C prog. Q3
turbo C prog. Q3  What is the difference between if and ladder if ? Describe ladder if with example. What is the purpose of the parameter passing ? please Describe with example.   if statement is used to write
(ForPro) turbo C prog. Q4
(ForPro) turbo C prog. Q4  I need to learn some easy foxpro program.. for example sum,interchange, loop etc
ModuleNotFoundError: No module named 'prog-edu-assistant-tools'
ModuleNotFoundError: No module named 'prog-edu-assistant-tools'  Hi...: No module named 'prog-edu-assistant-tools' How to remove the ModuleNotFoundError: No module named 'prog-edu-assistant-tools' error? Thanks  
ModuleNotFoundError: No module named 'prog_lang_detector'
ModuleNotFoundError: No module named 'prog_lang_detector'  Hi, My... named 'prog_lang_detector' How to remove the ModuleNotFoundError: No module named 'prog_lang_detector' error? Thanks   Hi, In your
Spring Hello World prog - Spring
Spring Hello World prog  I used running the helloworld prog code mentioned in http://www.vaannila.com/spring/spring-mvc-tutorial-1.html I'm getting null pointer exception. as shown below. I added all the jars and my
PKG_PROG_PKG_CONFIG: command not found
PKG_PROG_PKG_CONFIG: command not found  Hi, How to solve PKGPROGPKG_CONFIG: command not found error This error is coming while executing the configure script. Thanks
PKG_PROG_PKG_CONFIG: command not found
PKG_PROG_PKG_CONFIG: command not found  Hi, How to solve PKGPROGPKG_CONFIG: command not found error This error is coming while executing the configure script. Thanks
PKG_PROG_PKG_CONFIG: command not found
PKG_PROG_PKG_CONFIG: command not found  Hi, How to solve PKGPROGPKG_CONFIG: command not found error This error is coming while executing the configure script. Thanks
PKG_PROG_PKG_CONFIG: command not found
PKG_PROG_PKG_CONFIG: command not found  Hi, How to solve PKGPROGPKG_CONFIG: command not found error This error is coming while executing the configure script. Thanks
PKG_PROG_PKG_CONFIG: command not found
PKG_PROG_PKG_CONFIG: command not found  Hi, How to solve PKGPROGPKG_CONFIG: command not found error This error is coming while executing the configure script. Thanks
hashcode() and equals() - Java Interview Questions
hashcode() and equals()  can you give one hashtable prog using equals() and hashcode()?PLease..thanks in advance
resolution for prog
prog. using radio buttons for simple calculator
prog. using radio buttons for simple calculator  import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; class Calculator extends JFrame { private final Font BIGGER_FONT = new Font
prog. using radio buttons for simple calculator
prog. using radio buttons for simple calculator  import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; class Calculator extends JFrame { private final Font BIGGER_FONT = new Font
multiple fields in hashtable
please explain this prog
please explain this prog

Ads