COMP 202 Lecture 16: COMP 202 - Lecture 16 - Oct 12, 2016
jc123 and 40170 others unlocked
100
COMP 202 Full Course Notes
Verified Note
100 documents
Document Summary
How many times does the word hello get printed? for(int i=0; i<10; i++){ for(int j=0; j<10; j+=2){ //increments j by 2. The contents of the outer loop happens 10 times, so bye gets printed 10 times. The contents of the inner loop happens 5 times. However, the whole loop happens 10 times, so hello gets printed 5 x 10 = 50 times. To create an array: passstring[] names = new string[15]; int[] numbers = {1,2,3,4,5}; boolean[] values; //just declaring, not initializing. The size or length of an array is the number of elements that it contains. The first element in an array is at index 0. Array indices are written inside square brackets [ ]. Array example int[] a = new int[5]; for(int i=0; i