File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "arrays in java" Watch "arrays in java" New topic

arrays in java

vijayapriya thirumurugan

Joined: Apr 03, 2009
Posts: 16


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

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

Campbell Ritchie

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

Joined: Oct 13, 2005
Posts: 46367
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.
I agree. Here's the link:
subject: arrays in java
It's not a secret anymore!