CSE 116 Lecture Notes - Lecture 5: Bit Error Rate
Document Summary
Must declare it before we can use it: type, brackets, & name, names follow usual rules, variable is array of the type, so use any legal type, cannot use until after instantiating array. Object[] parkinglot = new car[17]; int [] bob; bob = new int[intvar]: type is for elements & must be assignable to variable"s type. Clicker question: which declaration is not legal? answer: c. float fbob[17]; Memory trace example int[] data = new int[3]; int[] al = data; for (int i = 0; i < data. length; i++) { data[i] = i * 2; } al[0] = 5; al = new int[1]; al[0] = 7; Within an array entries like individual variables. Clicker question: which is correct java code? answer: e: int s = 45; int[] d = new int[2]; d[s-4] = 32453; How do we organize data? arrays are the best option: use multi-dimensional arrays to create matrices.