Skip to content

Commit f6acce4

Browse files
committed
添加list代码
1 parent c9bb721 commit f6acce4

3 files changed

Lines changed: 57 additions & 16 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package cn.byhieg.collectiontutorial.listtutorial;
2+
3+
import java.util.ArrayList;
4+
import java.util.Collection;
5+
6+
/**
7+
* Created by byhieg on 17/2/7.
8+
* Mail to byhieg@gmail.com
9+
*/
10+
public class ArrayListDemo {
11+
12+
private ArrayList<Integer> listA = new ArrayList<>();
13+
private ArrayList<Double> listB = new ArrayList<>(5);
14+
private ArrayList<Integer> listC;
15+
16+
public ArrayList<Integer> getListA() {
17+
return listA;
18+
}
19+
20+
public ArrayList<Double> getListB() {
21+
return listB;
22+
}
23+
24+
public ArrayList<Integer> getListC() {
25+
return listC;
26+
}
27+
28+
public void setListC(Collection<? extends Integer> collection) {
29+
listC = new ArrayList<>(collection);
30+
}
31+
}

src/test/java/cn/byhieg/basistutorialtest/ExtendFatherTest.java

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cn.byhieg.collectiontutorialtest;
2+
3+
import cn.byhieg.collectiontutorial.listtutorial.ArrayListDemo;
4+
import junit.framework.TestCase;
5+
6+
import java.util.Iterator;
7+
8+
/**
9+
* Created by byhieg on 17/2/7.
10+
* Mail to byhieg@gmail.com
11+
*/
12+
public class ArrayListDemoTest extends TestCase {
13+
14+
15+
public void testList() throws Exception{
16+
ArrayListDemo demo = new ArrayListDemo();
17+
for (int i = 0 ;i < 10 ; i++){
18+
demo.getListA().add(i);
19+
}
20+
Iterator iterator = demo.getListA().iterator();
21+
while (iterator.hasNext()) {
22+
System.out.println(iterator.next());
23+
}
24+
}
25+
26+
}

0 commit comments

Comments
 (0)