Java Reference
In-Depth Information
< Day Day Up >
Puzzle 88: Raw Deal
This program consists of a single class representing a pair of like-typed objects. It makes heavy use
of release 5.0 features, including generics, autoboxing, varargs, and the for-each loop. See
http://java.sun.com/j2se/5.0/docs/guide/language for an introduction to these features [Java-5.0] .
The main method of this program gently exercises the class. What does it print?
import java.util.*;
public class Pair<T> {
private final T first;
private final T second;
public Pair(T first, T second) {
this.first = first;
this.second = second;
}
public T first() {
return first;
}
public T second() {
return second;
}
public List<String> stringList() {
return Arrays.asList(String.valueOf(first),
String.valueOf(second));
 
 
Search WWH ::




Custom Search