CS 161 Lecture 6: Lecture 6 - Array Lists

28 views3 pages

Document Summary

Arrays: store multiple values of the same type. Conveniently refer to items by their index. Need to know the size before declaring them: A collection storing an ordered sequence of elements. A list has a size(number of elements that have been added) Let"s consider the methods of a class called arrayintlist that represents a list using int[] The list"s size will be the number of elements added to it so far. Java includes a large set of powerful classes that provide functionality for storing and accessing collections of objects. The most basic, arraylist, can store any type of object. All collections are in the java. util package. When constructing an arraylist, you can specify the type of elements it will contain between < and > We say that the arraylist class accepts a type parameter, or that it is a generic class. Appends value at the end of list. Inserts given value at given index, shifting subsequent values right.

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

Related Questions