File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Code for user input for multi arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Code for user input for multi arrays

anise hollingshead
Greenhorn

Joined: Sep 07, 2006
Posts: 4
Hi,

I'm still having problems coding for a multi dimensional array with user input.

I have this code for the input:
for(int i = 0; i < coffeeArray2.length; i ++)
{
for(int j = 0; j < coffeeArray2[i].length; j ++)
System.out.print("Enter number of lbs of coffee for the first aisle:");
coffeeArray2[i][j] = myInput.nextInt();

But this is only getting me one column of numbers.

How do you get input for all the boxes in a 5x2 array?

Thanks!
Anise
Tim LeMaster
Ranch Hand

Joined: Aug 31, 2006
Posts: 226
That code fragment looks okay. Perhaps your problem is defining the array or the code you are using to go through the array to determine the values you have.

System.out.print("Enter number of lbs of coffee for the first aisle:");

Though I'd guess i is probably the aisle so this should be (the " + i + " aisle).
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Please continue this discussion in its original thread. (And please don't post duplicates. )


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Code for user input for multi arrays
 
Similar Threads
Out of Bounds Exception returns and the eradication thereof.
Array initialization
Comparing Values of multi dimensional array
Multi Dimension Array Storing
How to input user values multi-dimensional arrays