This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Murach's Java Programming and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Storing user input into 2-d Array  RSS feed

 
John Rhoter
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm trying to store two decimal numbers that the user will input into a two-dimensional array. The entire program is a GUI so, I'm only posting a little of the code

The problem I'm having is getting the user input to append to the next line in the text box.

Example, user enters "1" and "2" and presses the action button, then enters "3" and "4" In the output text box it should read as:

1 2
3 4

But right now it overwrites my number output.

Thanks in advance for the help!

 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It appears to me you are updating everything right, you are just not appending the right values. Also where do you read in the data? You could be only reading from the user once.

Hunter
 
Campbell Ritchie
Marshal
Posts: 54886
155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

And I shall be pedantic and remind you there is no such thing as a 2D array in Java; there are only arrays of arrays.
 
Campbell Ritchie
Marshal
Posts: 54886
155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the PM; if you look up arrays in the Java™ Tutorials, you find a "multidimensional array" is actually an array of arrays.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!