Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array

 
Sathya Shanmugam
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

Whether constructor is created in array object?

And also i don't understand this statement

int [] [] myarray = new int[3][]

usually my childhood memories about 2 dimensional array should be like this
int [][] myarray = new int[3][5]

That means 3 rows and 5 columns, but in java I don't understand..

Could anyone pls give some explanation..


Pls give me some example ..
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


will create an array containing three references to int arrays.

Initially these array references are null.

 
Pankaj Patel
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You Think That java doesnot support more than one dimensional array. If you see two dimensional array then it is array of Array. if you find three dimensional array then it is array of array of array. And So on...


1) int [] [] myarray = new int[3][]
Here in this case you are specifything that you have array with contains another array into it.


Now if you want all statement 1,2,3 and four into one line then you can do it as, int[][] myarray = new int[3][4].

Now assume, you want a zigzag array. So in that case what you will do?
In this case following code will come to rescue.



I hope this will help you little.
 
Sathya Shanmugam
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks patel,

now I got the clear picture
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic