2015-04-20 15:36:01 -07:00
|
|
|
|
//: generics/ListOfInt.java
|
2015-05-29 14:18:51 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
2015-04-20 15:36:01 -07:00
|
|
|
|
// Autoboxing compensates for the inability to use
|
|
|
|
|
// primitives in generics.
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
public class ListOfInt {
|
|
|
|
|
public static void main(String[] args) {
|
2015-05-05 11:20:13 -07:00
|
|
|
|
List<Integer> li = new ArrayList<>();
|
2015-04-20 15:36:01 -07:00
|
|
|
|
for(int i = 0; i < 5; i++)
|
|
|
|
|
li.add(i);
|
|
|
|
|
for(int i : li)
|
|
|
|
|
System.out.print(i + " ");
|
|
|
|
|
}
|
|
|
|
|
} /* Output:
|
|
|
|
|
0 1 2 3 4
|
|
|
|
|
*///:~
|