This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages 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
Pie
Posts: 50196
79
  • 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