| 19 | * �ڶ��������ʱ���Ҿ���ȷ��������Ԫ�ص����ͣ������Ժ������ӵ�ʱ�Ͳ�������κ����⡣ |
| 20 | */ |
| 21 | public class ArrayListDemo { |
| 22 | public static void main(String[] args) { |
| 23 | // �洢�ַ��������� |
| 24 | ArrayList array = new ArrayList(); |
| 25 | |
| 26 | array.add("hello"); |
| 27 | array.add("world"); |
| 28 | array.add("java"); |
| 29 | // array.add(new Integer(100)); |
| 30 | // array.add(100); // �Զ�װ�� |
| 31 | |
| 32 | Iterator it = array.iterator(); |
| 33 | while (it.hasNext()) { |
| 34 | String s = (String) it.next(); |
| 35 | System.out.println(s); |
| 36 | // Object obj = it.next(); |
| 37 | // // if (obj instanceof String) { |
| 38 | // // String s = (String) obj; |
| 39 | // // System.out.println(s); |
| 40 | // // } else if (obj instanceof Integer) { |
| 41 | // // Integer i = (Integer) obj; |
| 42 | // // System.out.println(i); |
| 43 | // // } |
| 44 | // System.out.println(obj); |
| 45 | } |
| 46 | |
| 47 | // String[] strArray = new String[3]; |
| 48 | // strArray[0] = "hello"; |
| 49 | // strArray[1] = "world"; |
| 50 | // strArray[2] = 100; |
| 51 | } |
| 52 | } |
nothing calls this directly
no outgoing calls
no test coverage detected