Results 1 to 5 of 5
- 03-08-2011, 11:46 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 6
- Rep Power
- 0
how to pass user input into multi-dimensional arrays
I am trying to put my user input into a 7-dimension array. each dimension should be used to keep a certain trait of a student. When a user wants to see the info on the student, she/he inputs the student id and all the info is displayed. The info should not be saved to a file, just saved while the program runs.
I have been trying to solve this for a while. Thanks for the help. :)
- 03-08-2011, 11:59 PM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
I think you want a 2 dimensional array. I could be wrong though, please clarify.
Do you want an array where each slot is a 7 item array? Or something else?
It may honestly be easier to create a class which has all the student data and then work with a 1 dimensional array.Java Code:int[][] a = new int[3][7]; where int[0] = int[7] int[1] = int[7] int[2] = int[7]
A 7 dimension array would be extremely challenging to keep track of.
it would be an array where each slot is a 6 d array, and each slot in the 6 d array would be a 5 d array, and so on, which would be pretty complex.
Even a 3d array would be quite complex and probably not what you want.
a 3d array of
Java Code:int[][][] = new int[2][2][2]; would be int[0] = int[][] int[0][0] = int[]
- 03-09-2011, 12:44 AM #3
I agree.
Using parallel arrays to model your data is a bad idea. Using multidimensional arrays are even worse. Do as suggested and use a class to hold your data instead.
- 03-09-2011, 05:21 AM #4
Member
- Join Date
- Mar 2011
- Posts
- 7
- Rep Power
- 0
Solution without a question
So, would this be the case of someone focusing on coding a solution without thoroughly examining the problem?
A 7-dimensional array? That should be a clue.
- 03-09-2011, 05:54 AM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
I have a feeling he just misworded it. Im assuming he meant a 2 d array with 7 item arrays, like this:
But again it would be better to use a class and a single array or arraylist.Java Code:String[][] people = new String[5]; people[0] = new String[7]; people[1] = new String[7]; ... people[4] = new String[7];
Similar Threads
-
How Multi-Dimensional arrays are represented in memory
By Riaz Ali in forum New To JavaReplies: 4Last Post: 08-01-2010, 09:25 AM -
need help with two dimensional array and setting it up using user input
By Peanuts1 in forum New To JavaReplies: 5Last Post: 11-26-2009, 07:01 PM -
Multi-dimensional arrays
By Implode in forum New To JavaReplies: 1Last Post: 09-15-2009, 08:50 AM -
[SOLVED] Multi-dimensional arrays
By thelinuxguy in forum Advanced JavaReplies: 3Last Post: 05-07-2009, 02:52 PM -
Need help with a program for high school regarding multi-dimensional arrays.
By Torque in forum New To JavaReplies: 2Last Post: 01-07-2008, 07:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks