Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Jayden Brown   on Jun 23 In Java Category.

  
Question Answered By: Eshe Chalthoum    on Jun 23

you can use the Hashtable class

this is a simple code:

import java.util.Hashtable ;
public class HashtableDemo{
public static void main(String[] args){
//This example creates a hashtable of numbers. It uses the names of the
numbers as keys:
Hashtable numbers = new Hashtable();
//public Object put(Object key,Object value);
numbers.put("one", new Integer(1));
numbers.put("two", new Integer(2));
numbers.put("three", new Integer(3));
//To retrieve a number, use the following code:
//public Object get(Object key);
Integer n = (Integer)numbers.get("two"); // (Integer) is casting
(ta7wil)
if (n != null) { //(n != null) : pour tester que cette valeur n'est pas
"null";
System.out.println("two = " + n);
}
}
}

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Generated servlet error: [javac] Compiling 1 source file Or get search suggestion and latest updates.


Tagged: