CS 1100 Lecture Notes - Lecture 24: Data Type

18 views2 pages
30 Nov 2016
School
Course
Professor

Document Summary

Last chapter we learned about single dimensional arrays (a line of values [elements]) Can also have multidimensional arrays (2d arrays, 3d arrays, etc. ) A 2d array has rows and columns and forms a grid/spread sheet like structure. A 3d array is like a cuboid, or rubics cube. 4d arrays, 5d arrays, etc. are possible, but not often used. It gets too confusing working with things more than 3 dimensions. Game board, a matrix, table of data, etc. Syntax for 2d array just like 1d arrays, but extra pair of []s. Each element in a 2d array has two indices. Int[][] x = new int[3][4]; x. length is number of rows to get the size of a particular row, index into x at that column x[3]. length ofte(cid:374), ea(cid:272)h ro(cid:449) is the sa(cid:373)e size, (cid:271)ut it s possi(cid:271)le to ha(cid:448)e differe(cid:374)t sizes. Processing 2d arrays as with 1d arrays, for loops are often used for processing 2d 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