CS 0401 Lecture 8: 1.31.17 Array Review, Passing arrays and Filling an Array from a File

45 views2 pages
School
Course
Professor

Document Summary

Collection of values of the same type stores consecutively in memory int arr[] = new int[5]; New int[5]; - allocates a chunk of memory big enough for 5 ints: will bring back the address of that chunk of memory (or throw exception if out of memory) Int arr[] creates a reference variable named arr: contains address of the first cell in memory chunk. The arr points to/ references the beginning of the array. Object: chunk of memory arr[i] = i*2; putting values into the array. For (int i=0 ; i< arr. length ; i++ ) array = [0][2][4][6][8] . length : asking how many cells of capacity the array has. array discipline: rules to follow in order to use an array correctly. When you declare an array you should declare an int names count or such to track how many value you have put into the array.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents