EXPLORING foreach LOOP
• foreach statement always declares an iteration variable (int pin), that automatically acquires the value of each element in the array
• foreach always iterates through the whole array, hence for selective access, use for loop
• foreach always moves forward, from 0 to Length-1, hence to move backward, use for loop
• foreach provides read-only copy of array, for modifications trust for loop
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment