CS 1114 Chapter Notes - Chapter 9: Ternary Operation, Code Segment

37 views2 pages

Document Summary

Recall ~ arraylists are not fixed in their capacity unlike arrays. Arrays are a collection type that can store a fixed number of items. Despite this restriction, access to the items held in an array are often more efficient than access to the items in a comparable flexible-size collection, and arrays can store either objects or primitive-type values: example: declaring array variables. In this situation int is the base type. private int[] hourcounts: example: creating array objects. hourcounts = new int[24], example: the following code segment instantiates a fixed-size collection that is able to store 10 strings. String[] names = new string[10]: example: indices begin at zero, not one. labels[5] = quit ; machines[0] = new ticketmachine(500); All arrays contain a field, length, that contains the value of the fixed size of the given array: example: iterating over an array. for(iterator it = tracks. iterator(); it. hasnext(); ) Two-dimensional arrays is a 1d array of 1d arrays.

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