CSE 8B Lecture 4: ArrayList and IO Files

46 views2 pages

Document Summary

An array"s size, once made, cannot be changed. An arraylist"s size (cid:272)an (cid:271)e (cid:272)hanged: like stringbuilder, but with arrays. Syntax: arraylist list = new arraylist(), the type has to be a non-primitive type. Appends element e to end of list: void add(int index, e element) Inserts element e at position index: e get(int index) Returns element at position index int size() Returns number of elements in list: e remove(int index) After using this method, all of the indices after the removed element change/ go up by 1. Removing 1 element means reducing the size by 1. For a program to process a file, it must interact with the operating system. It then gets access to the file: then it loads it into memory, finally it reads from the file. Scanner class are used for reading from a file. Printwriter class are used to write to a file.

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 Questions