Skip to content

Instantly share code, notes, and snippets.

@thmain
Last active February 22, 2016 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/0432332716e23d9c80fc to your computer and use it in GitHub Desktop.
Save thmain/0432332716e23d9c80fc to your computer and use it in GitHub Desktop.
import java.util.Hashtable;
public class SimpleHashTable {
int [] a = new int[5];
String [] arrNames = new String[]{"Sumit","Jain","Raghav","Garg","Gaurav","Rishi"};
Hashtable<Integer, String> ht = new Hashtable<Integer, String>();
public void insertValues(){
for(int i=0;i<arrNames.length;i++ ){
ht.put(i+1,arrNames[i]);
}
}
public String getValue(int key){
return ht.get(key);
}
public static void main (String [] args){
SimpleHashTable sht = new SimpleHashTable();
sht.insertValues();
System.out.println("All values inserted");
System.out.println("Employee with ID 1 is "+ sht.getValue(1));
System.out.println("Employee with ID 3 is "+ sht.getValue(6));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment