This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes arrays in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "arrays in java" Watch "arrays in java" New topic
Author

arrays in java

vijayapriya thirumurugan
Greenhorn

Joined: Apr 03, 2009
Posts: 16

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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Has nothing to do with Programming Diversions. Moving to the Java In General Forum.

Eric
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
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

Joined: Oct 13, 2005
Posts: 39478
    
  28
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: arrays in java