This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Printing an array using nested for loops? (Code edited) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Printing an array using nested for loops? (Code edited)" Watch "Printing an array using nested for loops? (Code edited)" New topic
Author

Printing an array using nested for loops? (Code edited)

Ashley Kin
Ranch Hand

Joined: Oct 18, 2011
Posts: 36
Hi, I'm trying to print this tic-tac-toe board out using arrays and nested for loop.
The board has 3 rows and 3 columns.



This is what I have so far, and it's printing the same String of the array board three times with || between.
I've been stuck for a while and I'd appreciate any help, thanks!

John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
The code you posted don't even compile. Please PostRealCode that you wrote.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

I dont think you need to be using Arrays.deepToString instead you can use the element variable. You are already traversing the array.


Mohamed Sanaulla | My Blog
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37926
    
  22
The way this website is set up, multiple whitespace does not appear. You should enclose your printout in code tags. I have edited your post, and you can see how much better it looks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing an array using nested for loops? (Code edited)
 
Similar Threads
2D array battleship
A for loop problem
cleaner code
printing character array vertically with loop
Battleships - guys please help me out!