February 2014
Beginner
1248 pages
62h 25m
English
Study each printArray method. The array element type appears in each method’s header (lines 22, 32 and 42) and for-statement header (lines 25, 35 and 45). If we were to replace the element types in each method with a generic name—T by convention—then all three methods would look like the one in Fig. 20.2. It appears that if we can replace the array element type in each of the three methods with a single generic type, then we should be able to declare one printArray method that can display the String representations of the elements of any array that contains objects. The method in Fig. 20.2 is similar to the generic printArray method declaration you’ll see in Section 20.3. The one shown here ...
Read now
Unlock full access