MCPcopy Create free account
hub / github.com/DuGuQiuBai/Java / ArrayListTest

Class ArrayListTest

day16/code/day16_Generic/src/cn/itcast_01/ArrayListTest.java:9–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7 * ��ArrayList�洢�Զ�����󲢱�����Ҫ����뷺��
8 */
9public class ArrayListTest {
10 public static void main(String[] args) {
11 // �������϶���
12 ArrayList<Student> array = new ArrayList<Student>();
13 // JDK7���������ԣ����η��ͣ������ƶ�
14 // ArrayList<Student> array = new ArrayList<>();
15
16 // ����Ԫ��
17 Student s1 = new Student("����", 18);
18 Student s2 = new Student("١���", 20);
19 Student s3 = new Student("����", 19);
20 Student s4 = new Student("������", 21);
21
22 // ����Ԫ��
23 array.add(s1);
24 array.add(s2);
25 array.add(s3);
26 array.add(s4);
27
28 // ����
29 Iterator<Student> it = array.iterator();
30 while (it.hasNext()) {
31 Student s = it.next();
32 System.out.println(s.getName() + "---" + s.getAge());
33 }
34 System.out.println("------------------");
35
36 for (int x = 0; x < array.size(); x++) {
37 Student s = array.get(x);
38 System.out.println(s.getName() + "---" + s.getAge());
39 }
40 }
41}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected