Java The Complete Reference, Seventh Edition
468 Part II: The Java Library The Map Classes Several classes provide implementations of the map interfaces. The classes that ca ...
Chapter 17: java.util Part 1: The Collections Framework 469 import java.util.*; class HashMapDemo { public static void main(Stri ...
470 Part II: The Java Library The TreeMap Class TheTreeMapclass extendsAbstractMapand implements theNavigableMapinterface. It cr ...
Chapter 17: java.util Part 1: The Collections Framework 471 // Deposit 1000 into John Doe's account. double balance = tm.get("Jo ...
472 Part II: The Java Library LinkedHashMapadds only one method to those defined byHashMap. This method is removeEldestEntry( )a ...
Chapter 17: java.util Part 1: The Collections Framework 473 TheComparatorinterface defines two methods:compare( )andequals( ). T ...
474 Part II: The Java Library // Display the elements. for(String element : ts) System.out.print(element + " "); System.out.prin ...
Chapter 17: java.util Part 1: The Collections Framework 475 // Put elements to the map. tm.put("John Doe", new Double(3434.34)); ...
476 Part II: The Java Library Method Description static <T> boolean addAll(Collection <? super T>c, T ...elements) I ...
Chapter 17: java.util Part 1: The Collections Framework 477 Method Description static int frequency(Collection<?>c, Object ...
478 Part II: The Java Library Several of the methods can throw aClassCastException, which occurs when an attempt is made to comp ...
Notice that several methods, such assynchronizedList( )andsynchronizedSet( ), are used to obtain synchronized (thread-safe) copi ...
480 Part II: The Java Library System.out.println("Minimum: " + Collections.min(ll)); System.out.println("Maximum: " + Collection ...
Chapter 17: java.util Part 1: The Collections Framework 481 static int[ ] copyOf(int[ ]source, intlen) static long[ ] copyOf(lon ...
482 Part II: The Java Library ThedeepEquals( )method can be used to determine if two arrays, which might contain nested arrays, ...
Chapter 17: java.util Part 1: The Collections Framework 483 Here,arrayis the array to be sorted. In the last form,cis aComparato ...
484 Part II: The Java Library // Binary search for -9. System.out.print("The value -9 is at location "); int index = Arrays.bina ...
Chapter 17: java.util Part 1: The Collections Framework 485 // To retrieve an element, an explicit type cast is needed // becaus ...
486 Part II: The Java Library These two improvements are made possible because each collection class has been given a type param ...
Chapter 17: java.util Part 1: The Collections Framework 487 Because of support for raw types, it is not necessary to immediately ...
«
21
22
23
24
25
26
27
28
29
30
»
Free download pdf