CECS 478 Lecture 22: 2D Arrays

42 views2 pages

Document Summary

How to print: int[][] num = new int [3][5]; int[][] num = {{1,2,3},{3,4,5},{4,5,6},{5,6,7}} num[2][1] = 10 for(int i = 0; i < num. length; i++)// # of rows for(int j=0; j < num[0]. length; j++)//#of columns. Arraylists can grow and shrink as needed. Arraylists class supplies methods for common tasks such as inserting and removing. To display values of an arraylist: use system. out. print. To declare different type other than string: use integer, double. When you first declare an arraylist, it has size 0. To access an element in an arraylist, use get . To obtain the size of an arraylist, use size . To add an element, use method add names. add( bob ); names. add( emily ); { bob , emily }; names. size(); names. get(0); int[] num = {1,2,3}; names. set(1, jay ); To remove an element, use remove names. remove(0); To set an element to a new value, use set . Go through the whole list and delete c :

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