aspose file tools
The moose likes Beginning Java and the fly likes multi-dimensional array Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "multi-dimensional array" Watch "multi-dimensional array" New topic
Author

multi-dimensional array

luk Hann
Ranch Hand

Joined: Jan 29, 2001
Posts: 48
Hi all,
How does three-dimensional array work?
Thanks.
Luk
Elisabeth Van
Ranch Hand

Joined: Feb 09, 2001
Posts: 42
Kind of a generic question, but I'll try to explain as best I can (and let me know how I do, because something I'm doing for work right now is preparing to teach an intro-level Java class--as little as I know, I happen to be the "expert" in our department )
Suppose the easiest way to start is with 2-dimensional arrays, which are easy to get a handle on--it's just an array of arrays.
So for instance, suppose I was keeping an array of the mileage at which I got the oil changed in my vehicles.
So suppose:
int miles[][] = new int[2][];
miles[0] = {3000, 6000, 9000, 12000, 15000};
miles[1] = {3000, 8000, 14000, 20000};
Pretty simple concept. Now, take it to 3 dimensions--we'll keep track of the mileage of everyone in the neighborhood
so now we would have miles[][][]
miles[0] = {{3000, 6000, 9000, 12000, 15000}, {3000, 8000, 14000, 20000}}; //me
miles[1] = {{3000, 6000, 10000}, {5000, 10000, 15000, 20000}, {3000, 7000}}; //my neighbor, who has 3 cars
and so on...
Hope that helps a little, or at least raises some further questions that'll help clarify thing.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4092
    
    1
good example


SCJP
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: multi-dimensional array
 
Similar Threads
about hashmap implementation of arraylist
Object reference array assignment
How to create this String array
one more certpal question
Doubt in Array Declaration