CS 2114 Lecture Notes - Lecture 20: Mobile Suit Gundam, Github, Iterator
Document Summary
Lecture 20 iterators & generics ii & intro to sorted lists. Github workshop this week: wednesday, april 4 or thursday, april 5. Project v preliminary submission is due designs will be due monday, april 9; Project v final submission is due thursday, april 26. Project iv is due monday, april 16 (less than two weeks away). Can have multiple iterators (both moving size by side, different directions, etc. The enhanced for loop creates an iterator object and implicitly calls its hasnext and next methods: example: has an iterator inside. for (string nextstr : mylist) System. out. println(nextstr): example: has an iterator inside. public static double getaverageheight(iterable people) for (person person : people) { count++; totalheight += person. getheight(); Commonly want to perform some process on all objects. Performing some kind of update/change on each object. Lists have indices so we can use an index access all of the objects. If the underlying structure is a linked chain, this becomes (cid:4666)(cid:4667).