Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to enter whole row of elements into 2d array

 
Kyle Wettengel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm experimenting with arrays and while I can figure out how to enter the elements of a 2d-array based on user input I cannot figure out how to prompt the user to separately enter entire rows of the 2d-array (with a space in between each number) rather then entering each number then pressing enter. Could I get some help here? I know this will be on my next test, thanks guys!

Here's my code:

 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle Wettengel wrote:
System.out.println(isConsecutiveFour(array));


Is this all of your code? Where's the isConsecutiveFour() method defined?

EDIT:
Here, I added a couple of lines so that the information for each row is prompted and then printed out.

 
Campbell Ritchie
Sheriff
Posts: 48424
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java does not support 2D arrays. What you have is an array of arrays.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic