CS 121 Lecture Notes - Lecture 30: Dynamic Array, Iterator
Document Summary
System. out. println( hello ); count2++: a: 15 (cid:498)hello(cid:499)s in groups of 3 will be printed out, q: how many times will the string (cid:498)here(cid:499) be printed? count1 = 1; while (count1 <= 10) count2 = 1; while (count 2 < 20) System. out. println( here ); count2++: a: 10 x 19 = 190. Iterators: an object that allows you to process a collection of items, one at a time. (ex: student name list saved in a text file. ) An iterator class in java should provide two basic methods: next method: returns the next item, hasnext method: returns true if there is at least one more item to process. Array list: class manages a sequence of objects with the same type: syntax: creates an arraylist of string type. The size can grow and shrink as needed. Arraylist class supplies methods for many common tasks, such as inserting and removing elements.