Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

arrays in java

 
vijayapriya thirumurugan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi,

i have two dimentional array. my problem is in that two dimentional array every element is of the structure (struct) form which can hold two fields one is integer data, another one is list of elements(array). so can you give me some example for array of structure(struct) and explain me.
Thank you so much in advance..
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has nothing to do with Programming Diversions. Moving to the Java In General Forum.

Eric
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as a 2-D array in Java; there are only arrays of arrays.
There is no such things as a struct in Java, only classes enums and interfaces. Which language are you writing in?

You create a class which has the two ints in, let's call it OrderedPair. Then you declare and initialise an OrderedPair[][] array of arrays.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I misread your original requirement. You want a NumberedList class with an int field and a List field. Then a NumberedList[][] array.

A number and a List sounds like a Mapping; looking at this interface and the remainder of that tutorial thread might suggest an alternative way to handle your data.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic