INSY 3433 Lecture Notes - Lecture 5: Cd1, Reference Type

33 views3 pages

Document Summary

Arrays: store related data items of same type, fixed size once created, reference type. Arrays defining: define & create space: int[] myarray = new int[10], define array variable w/ space created later int [] myarray; int asize = 10; myarray = new int [asize]; Arrays defining & setting: define & initialize w/ values: int[] myarray = {1, 3, 5}, define, then initialize w/ some values int [] myarray = new int[6]; myarray[0] = 1; myarray[1] = 3; myarray[2] = 5; Index aka subscript & is the positive number in square brackets: 1st element of an array has index 0. Array length: arrays have a property for the count of their elements length, ex: c. length, highest valid index is length-1. Passing arrays to a method: to pass array argument to a method, caller specifies array name w/out bracket, ex method call: modifyarray(hourlytemperatures), ex method signature: static void modifyarray(int temps[]

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