CSCI 1006 Lecture Notes - Lecture 12: Increment And Decrement Operators
Document Summary
It repeats the code until the test becomes false. It is not recursion, and thus does not eat up memory. A for loop is optimized for counter-based iteration. For (initialize counter; test; modify counter) { code }. For example for(int index = 0; index < a. length; index++). The initialize counter happens before looping, only once. The test is evaluated at the beginning of each iteration. The modification occurs at the end of every iteration. An array is a type of data structure. A data structure is a type of data used to store multiple pieces of information in one piece. An array is a contiguous block of memory used to store multiple values of a single type. Individual values are referenced by their index, or position in the array. The index starts at 0 and goes up to n 1, if there are n numbers. Indexes cannot be negative numbers; else they are invalid.