types allows us to write general kinds of data structures that only make minimal assumptions about the elements they store in code fragment we sketch how to build directory storing pairs of objects implementing the person interface the remove method performs search on the directory contents and removes the specified person pairif it existsandlike the findother methodit uses the equalto method to do this code fragment personpairdirectory sketch of class nowsuppose we have filled directorymydirectorywith pairs of student objects that represent roommate pairs in order to find the roommate of given student objectsmart_onewe may try to do the following (which is wrong)student cute_one mydirectory findother(smart_one)/wrongthe statement above causes an "explicit-cast-requiredcompilation error the problem here is that we are trying to perform narrowing conversion without an explicit cast namelythe value returned by method findother is of type person while the variable cute_oneto which it is assignedis of the narrower type studenta class implementing interface person thuswe use cast to convert type person to type studentas followsstudent cute_one (studentmydirectory findother(smart_one)casting the value of type person returned by method findother to type student works fine as long as we are sure that the call to mydirectory findother is really giving us student object in generalinterfaces can be valuable tool for the design of general data structureswhich can then be specialized by other programmers through the use of casting generics