Java Reference
In-Depth Information
< Day Day Up >
Puzzle 71: Import Duty
In release 5.0, the Java platform introduced a number of facilities that make it easier to work with
arrays. This program uses varargs, autoboxing, static import (see
http://java.sun.com/j2se/5.0/docs/guide/language [Java-5.0] ) and the convenience method
Arrays.toString (see Puzzle 60 ). What does the program print?
import static java.util.Arrays.toString;
class ImportDuty {
public static void main(String[] args) {
printArgs(1, 2, 3, 4, 5);
}
static void printArgs(Object... args) {
System.out.println(toString(args));
}
}
 
 
Search WWH ::




Custom Search