E81 CSE 131 Lecture 3: Arrays Syntax and Usage

30 views2 pages
magentarat813 and 20 others unlocked
E81 CSE 131 Full Course Notes
8
E81 CSE 131 Full Course Notes
Verified Note
8 documents

Document Summary

String[] names = { bob, carol, alice }; The type of each element contained in the array is followed by an opening and closing bracket. Either list the array elements in braces or use new provision for elements you will assign later. 131 is the number of elements we want to put inside of the array. Referencing elements of an array names[ i ] References the ith element of the names array. In place of i, any integer-valued expression can be used. The elements of the array start with index 0. And therefore stop just 1 short of the length of the array. String[] names = { alice, bob, carol }; names[0] has alice names[1] has bob names[2] has carol names. length is 3. String[] names = {alice, bob, carol}; names[2] = names[0]; carol now has the value of alice names[0] = names[1];

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