• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

6x6x6x6x6 array representation

 
Eric Racin
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 151
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eric Racin
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Eric Racin
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getRealPath() is a good idea. However, from my research it looks like
it will return \index.html.
getPathTranslated() will probably return something like
\Tomcat\webapps\Root\index.html

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
\Tomcat4.1\webapps\carbonapp3\WEB-INF\classes

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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric please UseOneThreadPerQuestion. You already asked the question here. I'll close that one because this one has more activity.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic