Solved

Multidimesional arrays in java, similar to vba

Posted on 2008-10-16
5
291 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
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 400 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 100 total points
ID: 22738762
0
 

Author Closing Comment

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

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
use lov values 2 61
Is Applet the way to go for my drag and drop system? 8 25
hashmap order 17 36
add criteria to query in VB, Access 2003 2 7
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

840 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