File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes 6x6x6x6x6 array representation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "6x6x6x6x6 array representation" Watch "6x6x6x6x6 array representation" New topic

6x6x6x6x6 array representation

Eric Racin

Joined: Oct 13, 2010
Posts: 12
I need this multi-dimensional array (6x6x6x6x6 = 7776 elements):
This is a portion of the data:
0 0 0 0 0 445
91 151 179 180 155 544
224 368 437 435 370 673

How do I know where to put the brackets?
public int iArray[][][][][] = ?
Do I do this?
{{{{{{ 0, 0, 0, 0, 0, 445}
{ 91, 151, 179, 180, 155, 544}
{224, 368, 437, 435, 370, 673}

Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
Good lord why would you want to use brackets to instantiate a 6x6x6x6x6 array? I would actually argue that using an array of that size is a sure sign of a bad design, but that's another point.

Why don't you just do something like this:

Then loop through to set each index?

But, again, there is probably a much better way to go about doing this without using such a ridiculous array.

PS- Are you sure you don't just need a 2-dimensional array?
Darryl Burke

Joined: May 03, 2008
Posts: 4523

It helps to remember that in Java, a multi dimensional array is an array of arrays.

So an int[] is an array of ints
an int[][] is an array of int[]
an int[][][][][] is an array of int[][][][]

I agree with Kevin that having to use a 5 dimensional array is likely an outcome of bad design, and there is probably a better way of doing whatever it is you are doing. Would you like to share that? the problem, not any solution that has come to your mind.

luck, db
There are no new questions, but there may be new answers.
Eric Racin

Joined: Oct 13, 2010
Posts: 12
Point well taken. The real problem is that are production Tomcat Servlet
will not read anything from a file (while the test Server works fine!)
This is a brute force attempt to have the data within the Servlet itself, but
I am confused as to where to put the brackets.

(The 6x6x6x6x6 array results from the possible permutation of choices from the user:
5 fields with 6 choices per field)
Rob Spoor

Joined: Oct 27, 2005
Posts: 19649

Let's focus on the main problem - why you can't read from the file. Are you reading the file from the right location? Are you using ServletContext.getRealPath?

How To Ask Questions How To Answer Questions
Eric Racin

Joined: Oct 13, 2010
Posts: 12
getRealPath() is a good idea. However, from my research it looks like
it will return \index.html.
getPathTranslated() will probably return something like

The needed file was opened successfully at
\Tomcat\bin on one Server.

On the problem Server I also placed it in
\Tomcat4.1\webapps\ROOT and

I guess I could sprinkle it throughout the directories but I feel like I
am on a wild goose chase. The permissions have been checked as
well as the Server's security model. That is why I was giving up
and placing the array within the Servlet.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Eric please UseOneThreadPerQuestion. You already asked the question here. I'll close that one because this one has more activity.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
I agree. Here's the link:
subject: 6x6x6x6x6 array representation
Similar Threads
Passed With 141/155 (~91%)
Passed SCJD with 151/155
Need help on animation using GUI Builder.
Passed SCJD with a score of 151/155