By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 819 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

Array of Arrays

P: n/a
Hi,

I am a C programmer trying to figure out a simple way of defining a 2D
array.
In C i would simply do:

int dateArray[5][3] = {5,21,2004,
7,23,1979,
5, 6,1949,
6, 2,1977,
2,15,1975};

In java however I am not sure how to do this. From what I have read so
far I know of one way.

int[][] dateArray = new int[5][3];
dateArray[0][0] = 5;
dateArray[0][1] = 21;
dateArray[0][2] = 2004;
....

Is there a quicker way to do this, similar to C.

Thanx

Joe
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Liz

"Joe Ray" <ra****@hotmail.com> wrote in message
news:46*************************@posting.google.co m...
Hi,

I am a C programmer trying to figure out a simple way of defining a 2D
array.
In C i would simply do:

int dateArray[5][3] = {5,21,2004,
7,23,1979,
5, 6,1949,
6, 2,1977,
2,15,1975};

In java however I am not sure how to do this.
It is the same in java, but you need extra curleys.
int x[][] = {{1,2,3}, {2,3,4}};
And you don't need to specify the size unless you want to.
From what I have read so
far I know of one way.

int[][] dateArray = new int[5][3];
dateArray[0][0] = 5;
dateArray[0][1] = 21;
dateArray[0][2] = 2004;
...

Is there a quicker way to do this, similar to C.

Thanx

Joe

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.