aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Multi Dim Array Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Multi Dim Array Question" Watch "Multi Dim Array Question" New topic
Author

Multi Dim Array Question

Mike Cunningham
Ranch Hand

Joined: Nov 14, 2000
Posts: 129
It's safe to say we will probably be tested on this concept during the SCJP exam.
I'm not sure of the answer though....
Array 1:
int[][] arrayA = new int[5][10];
- Per my reading material...the first index operator represents five rows...second index represents 10 columns.
Array 2:
int[][] arrayA = { {1,2,3} , {4,5,6} , {7,8,9} };
- I don't understand the nested curly braces method...please help.
- Mike
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Right,
1. 5 rows 10 columns
2. 3 rows 3 columns as in
row 0: 1,2,3
row 1: 4,5,6
row 2: 7,8,9
This is a short way of declaring and initializing an array in one shot !
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Mr Iftikhar
Ranch Hand

Joined: Oct 12, 2001
Posts: 39
You can see this array in this direction for you convienient.
int[][] arrayA = { {1,2,3} ,
{4,5,6} ,
{7,8,9} };
Now it become 3x3( rows by column ) matrix and in java it contain 0,1,2 rows as well as 0,1,2 column.

----> Row0 Column0 Row0 Column1 Row0 Column2
----> Row1 Column0 Row1 Column1 Row1 Column2
----> Row2 Column0 Row2 Column1 Row2 Column2



java language
 
Consider Paul's rocket mass heater.
 
subject: Multi Dim Array Question