[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Examples] [Book] [Tutorial] [API]
Back to Documentation and Testing. On to Algorithm Analysis.
Held Tuesday, February 16
Summary
Contents
Handouts
Notes
type[] name = new type[size];
stuff,
you would write
double[] stuff = new double(5);
type[] name = { val1, val2, ..., valn };
int[] stuff = {3, 2, 6, 5};
name[index]
stuff with
stuff[3]
i held the value 3, then we could get
element 3 of the stuff with
stuff[i]
name.length
public double sum(double[] stuff) {
double total = 0; // The total of the numbers in stuff
int i; // A counter variable for stepping through
// the array
// Step through the array, adding each subsequent value
for(i = 0; i < stuff.length; i = i + 1) {
total = total + stuff[i];
}
// Return the total value
return total;
} // sum
History
Back to Documentation and Testing. On to Algorithm Analysis.
[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Examples] [Book] [Tutorial] [API]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS152/99S/Outlines/outline.14.html
Source text last modified Wed Feb 17 09:48:25 1999.
This page generated on Fri Mar 12 13:12:17 1999 by SiteWeaver. Validate this page's HTML.
Contact our webmaster at rebelsky@math.grin.edu