Last active
February 22, 2016 03:19
-
-
Save thmain/0432332716e23d9c80fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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