Solved

Multidimesional arrays in java, similar to vba

Posted on 2008-10-16
5
294 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 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

705 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