public class HashExercise { /** * This app generates hashcodes of strings "aa", "ab"... * * @param args */ private static final int SIZE=512; public static void main(String[] args) { String[] letters = {"a","b","c","d","e","f","g","h", "i","j","k","l","m","n","o","p","q","r","s","t", "u","v","w","x","y","z" }; // Lab 7 LookupTable, used to store (hashcode, letters) pairs LookupTable lt = new LookupTable(); int hashcode; // hashcode value to be computed int duplicates=0; // number of duplicate hashcodes generated // first, generate the hashcodes for the string combinations for(String char1: letters ) { // iterate a...z for(String char2: letters ) { // iterate a...z String s = char1+char2; // "aa"..."zz" 26*26 in all hashcode = createHashcode(s); System.out.println(s + " hashcode is: " + hashcode ); // String duplicate = lt.put(hashcode, s ); // if( duplicate != null ) { // check if already existing // System.out.println(s+" and " + duplicate + " have a duplicate hashcode: " + hashcode ); // } } } } // create a hashcode from a String private static int createHashcode(String s) { int hashcode = 0; for( int i=0; i