Solved

Multidimesional arrays in java, similar to vba

Posted on 2008-10-16
5
290 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
  • 2
  • 2
5 Comments
 
LVL 24

Expert Comment

by:sciuriware
Comment Utility
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
Comment Utility
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 400 total points
Comment Utility
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 24

Assisted Solution

by:Tomas Helgi Johannsson
Tomas Helgi Johannsson earned 100 total points
Comment Utility
0
 

Author Closing Comment

by:billyleo
Comment Utility
cheers guys - thanks for your help
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
The viewer will learn how to implement Singleton Design Pattern in Java.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now