Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

3-Dimensional Arrays?!?

807600Sep 21 2007 — edited Sep 22 2007
I've got a lab project that requires me to read in questionnaire data (3 integers) from a file, then put those integers into
a 3-Dimensional array. Here's the idea:

int [][][] poll = new int [4][3][2]; // 4 Age Ranges, 3 Opinions, 2 Genders
int readAge=0, readOpinion=0, readSex=0;

// Read data from file
readAge = scan.nextInt();
readOpinion = scan.nextInt();
readSex = scan.nextInt();

// Store Age, Opinion, Sex into 3D array.
poll[i][j][k] = poll[readAge][readOpinion][readSex]; // ????

Do I need to use a nested for loop (i,j,k) to access and assign this?
How do I put those values into the array?
What's the best way to visualize 3d arrays?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 20 2007
Added on Sep 21 2007
4 comments
410 views