Spec-Zone .ru
спецификации, руководства, описания, API
|
List
. Describe them, and note the limitations of each.Set
, List
, Queue
, and Map
. For each of the following four assignments, specify which of the four core interfaces is best suited, and explain how to use it to implement the assignment.
import java.util.*; public class SortMe { public static void main(String args[]) { SortedSet<StringBuffer> s = new TreeSet<StringBuffer>(); s.add(new StringBuffer("Red")); s.add(new StringBuffer("White")); s.add(new StringBuffer("Blue")); System.out.println(s.first()); } }
FindDups example
and modify it to use a SortedSet
instead of a Set
. Specify a Comparator
so that case is ignored when sorting and identifying set elements.List<String>
and applies
String.trim
to each element. To do this, you'll need to pick one of the three iteration idioms that you described in Question 1. Two of these will not give the result you want, so be sure to write a program that demonstrates that the method actually works!