Solved

Multidimesional arrays in java, similar to vba

Posted on 2008-10-16
5
293 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DTD and JAVA versions 1 52
Github api to fetch the number of collaborators in a git repo 1 62
Java List 4 70
Modify Text File with Excel Macro 13 39
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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 …

734 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