File tree Expand file tree Collapse file tree
main/java/cn/byhieg/collectiontutorial/listtutorial Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments