Duke CPS 006 - Two Dimensional Arrays

Unformatted text preview:

Two Dimensional ArraysArrays of ArraysCompSci 622.1Two Dimensional ArraysJust an extensions of the basic idea . . .int[][] matrix = new int[ROWS][COLS]; . . .for (int r = 0; r < matrix.length; r++) { for (int c = 0; c < matrix[0].length; c++) { . . . System.out.println(matrix[r][c]); }}CompSci 622.2Arrays of ArraysSimilar ideaWARNING: All rows the same length??? . . .String[] smith = {”Jason”, ”Sarah”, ”Oscar”, ”Ben”};String[] jones = {”Cindy”, ”Ellen”, ”Sean”, ”Betty”};String[] wells = {”Henry”, ”David”};String[][] friends = {smith, jones, wells};for (int r = 0; r < friends.length; r++) { for (int c = 0; c < friends[r].length; c++) { . . . System.out.print(friends[r][c] + ” ”); }


View Full Document

Duke CPS 006 - Two Dimensional Arrays

Download Two Dimensional Arrays
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Two Dimensional Arrays and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Two Dimensional Arrays 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?