Collection<dataType> variable = new Collection<dataType>();
import java.util.List; import java.util.ArrayList; public class dailyCode { public static void main(String[] args) { List<String> strList = new ArrayList<String>(); strList.add("aaa"); strList.add("bbb"); strList.add("ccc");
List<Integer> intList = new ArrayList<Integer>(); intList.add(111); intList.add(222); intList.add(333);
printList(strList); printList(intList); }
private static void printList(List<?> list) { for(Object obj : list) { System.out.println(obj); } System.out.println("---"); } } |
'프로그래밍 > JAVA' 카테고리의 다른 글
람다 표현식 (Lambda Expression) (0) | 2016.11.24 |
---|---|
Arrays class Example (0) | 2016.11.23 |
Hashtable and HashMap Example (0) | 2016.11.21 |
arraycopy Example (0) | 2016.11.19 |
scheduleAtFixedRate vs. scheduleWithFixedDelay (0) | 2016.11.18 |
Callback using interface (0) | 2016.11.17 |
Singleton Design Pattern (0) | 2016.11.16 |