Computer Science Review SASHA P KEVIN L Arrays

  • Slides: 6
Download presentation
Computer Science Review SASHA. P & KEVIN. L

Computer Science Review SASHA. P & KEVIN. L

Arrays! Arrays are used to make multiple GUI and variables at once. An example

Arrays! Arrays are used to make multiple GUI and variables at once. An example would be: String ^ Type [] s = new String [X]; ^ Name ^ # of value

Example of how it is used. //Declare the array String [ ] days_week; days_week

Example of how it is used. //Declare the array String [ ] days_week; days_week = new String [7] ; //Assign data to each box/slot of the defined array days_week [0] = “Monday” ; days_week [1] = “Tuesday” ; days_week [2] = “Wednesday” ; days_week [3] = “Thursday” ; days_week [4] = “Friday” ; days_week [5] = “Saturday” ; days_week [6] = “Sunday” ; System. out. print. In(days_week[1] + “ we have Java class. “) ;

Two Dimensional Arrays! Similar to normal arrays, two dimensional arrays use boxes arranged in

Two Dimensional Arrays! Similar to normal arrays, two dimensional arrays use boxes arranged in rows and columns to store data. In this case require 2 numbers, a coordinate pair, to identify each slot/box instead of one to allow the programmer to have more elaborate data storage. This allows accuracy to the program whilst making the program in a gridlike formation. An example would be: String [ ][ ] s = new String [X][Y]; ^ ^ Type Name ^ ^ # of coordinates

How it works Column 1 Column 2 Column 3 Column 4 Row 1 X[0][0]

How it works Column 1 Column 2 Column 3 Column 4 Row 1 X[0][0] X[0][1] X[0][2] X[0][3] Row 2 X[1][0] X[1][1] X[1][2] X[1][3] Row 3 X[2][0] X[2][1] X[2][2] X[2][3]

How to create 2 dimensional arrays on practice

How to create 2 dimensional arrays on practice