Hi all, How does three-dimensional array work? Thanks. Luk
Elisabeth Van
Ranch Hand
Joined: Feb 09, 2001
Posts: 42
posted
0
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
posted
0
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.