chap listsstacksand queues public int size(/return list size return list length()figure (continuedfind the record prior to removalwe would still need to shift down the remaining records in the list to fill the gap left by the remove operation given two keyswe have not properly addressed the issue of how to compare them one possibility would be to simply use the basic ==operators built into java this is the approach taken by our implementations for dictionaries shown in figure if the key type is intfor examplethis will work fine howeverif the key is pointer to string or any other type of objectthen this will not give the desired result when we compare two strings we probably want to know which comes first in alphabetical orderbut what we will get from the standard comparison operators is simply which object appears first in memory unfortunatelythe code will compile finebut the answers probably will not be fine in language like +that supports operator overloadingwe could require that the user of the dictionary overload the ==operators for the given key type this requirement then becomes an obligation on the user of the dictionary class unfortunatelythis obligation is hidden within the code of the dictionary (and possibly in the user' manualrather than exposed in the dictionary' interface as resultsome users of the dictionary might neglect to implement the overloadingwith unexpected results againthe compiler will not catch this problem the java comparable interface provides an approach to solving this problem in key-value pair implementationthe keys can be required to implement the comparable interface in other applicationsthe records might be required to implement comparable the most general solution is to have users supply their own definition for comparing keys the concept of class that does comparison (called comparatoris quite important by making these operations be generic parametersthe requirement to supply the comparator class becomes part of the interface this design is an example of the strategy design patternbecause the "strategiesfor comparing and getting keys from records are provided by the client in many casesit is also possible for the comparator class to also extract the key from the record typeas an alternative to storing key-value pairs we will use the comparable interface in section to implement comparison in heapsand in to implement comparison in sorting algorithms