Random rNumGen = new Random() ; Person p1 ; List aList1 = new ArrayList() ; List aList2 = new ArrayList() ; Map pMap = new HashMap() ; int numPeople = 50000 ; for (int i = 0 ; i < numPeople; i++) { p1 = new Person(i,"Pat"+i, 100+rNumGen.nextInt(80), 20+rNumGen.nextInt(70) ) ; pMap.put(i,p1) ; // add to map aList1.add(p1) ; // add to list that will be shuffled aList2.add(p1) ; // add to list that will be sorted } Collections.shuffle(aList1) ; Collections.sort(aList2) ; // create an array of search keys to use for each of the three int numSearches = 25000 ; int searchKeys[] = new int[numSearches] ; ; for (int i = 0 ; i < numSearches ; i++) { searchKeys[i] = rNumGen.nextInt(numPeople) ; } long startTime, endTime, elapsedTime ; int sKey ; // time the searching using map startTime = System.currentTimeMillis() ; Person p2 ; for (int i = 0 ; i < numSearches ; i++) { sKey = searchKeys[i] ; p2 = pMap.get(sKey) ; } endTime = System.currentTimeMillis() ; elapsedTime = (endTime - startTime) ; System.out.println("Search Time using map = " + elapsedTime/1000.0) ;