Handout2 1 - CCF14? v S :q m Ln l a rL y r ! Prncr:m...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CCF14? v S :q m Ln l a rL y r ! Prncr:m handout #2 f-I iant Prncr:m Arr:rrIntT,ie1_Cl iont i:rre public cl-ass ArraylntListclient { public void main (String static [ ] args) : new ArraylntList l-istl Array-IntList : new ArraylntList l-ist2 ArraylntList !rJLf.auu { O; O; Iist1. li-st1. list2. Iist2. add add add add 6); 43) i q7 \ . 12) ; -B); size size " " O () + + ); ); listl); l-ist2) (list1. Syst.em.out.println (tist2. System.out.printlrt System.out.pri-nt. In("list1: System.out.printfn("list2: listl.add(0, 2); 5) ; Iist1. add (2, System. out.println for ) for ) ; ( "Iist1 after some adds: " + Iistl) ; (int i : I; i < 10; i- +: System.out.println("index 2) { ofrr+ i +rt : " + listl.indexOf(i)); (int i < listl.sizeO; i:0; for System.ouL.println("get i-++; { rr + r | " returns tr I Li-sCl.get(i) ); 3 2 1 : 16, 43, 91 ) list list2: l'72, *Bl after some adds: listl -1 1: index of indexof3:-1 rndexof5:2 -7 : -1 index of indexof9:-1 o "e rfor O refurns 2 Y nUo r 9 Y npf Yvu c vr e f Y n u ef e Y far for for for I 2 3 4 ro1_urnS rc'f urns returns refurnS T i 12, 6, 5, 43, 911 6 5 43 91 oF irr'JOVq D A r^m r r t u- 9 ! e l r r A 17 lnf n !r! ra: J a IT L ! I J L . // CIass Arraylntl-ist can be used to store a list of integers. public class pr lvate private public ArraylntList { int I I elementData; int size; static finalint // /,/ -ist of current i-ntegers number of 100; elements in the l-ist DEFAULT-CAPACITY Iist of default an empty constructs / / post: publlc ArrayrntList O { (DEFAULT_CAPACITY ) ; this I capacity ...
View Full Document

Ask a homework question - tutors are online