?
Solved

Multidimesional arrays in java, similar to vba

Posted on 2008-10-16
5
Medium Priority
?
297 Views
Last Modified: 2012-05-05
Hi,

I have the pleasant task of implementing a model that is currently in excel in java. this will use alot of probability lookups which are currently stored in multidimensional arrays in vba (similar to Dim tree() as Double, ReDim tree(2, 2, 6, 6, 7, 7, 1) As Double)

i was wondering how would be the easiest way of implementing this in java?

I was thinking along the lines of int[][][][][][][] i = new int[2][2][6][6][7][7][1]  but this obviously could get messy

thanks in advance
0
Comment
Question by:billyleo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 22731589
A multi-dimensional array in JAVA is an array of arrays of arrays .......

Unlike the old FORTRAN style not all dimensions have to be equal.
Thus you can build a tree-like construct.

You could also make use of (named!) arrays or ArrayLists so that the 'trunk' of
your construct is not anonymous but names 2 'branches' that have 2 'branches' each
and so on.

;JOOP!
0
 

Author Comment

by:billyleo
ID: 22733160
Can you give me an example of what you mean?
For some reason i think using arraylists could get very messy, esp when referencing a low level branch?
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 1600 total points
ID: 22733809
Take book:
The chapters are 1 dimension, their length is variable in pages,
The lines are 1 dimension, their length is variable in lines,
each line is an array of characters,  their length is variable in characters.

char[][][][]book;
char[][][]chapter;
char[][]page
char[] line;

I agree that ArrayLists can be a problem in retrieval,
but in the build-up phase, they come out handy.

;JOOP!
0
 
LVL 25

Assisted Solution

by:Tomas Helgi Johannsson
Tomas Helgi Johannsson earned 400 total points
ID: 22738762
0
 

Author Closing Comment

by:billyleo
ID: 31506707
cheers guys - thanks for your help
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
A solution for Fortify Path Manipulation.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question