This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 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

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

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: 3056

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

Joined: Oct 13, 2005
Posts: 36592
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:
subject: Printing an array using nested for loops? (Code edited)
Similar Threads
A for loop problem
cleaner code
printing character array vertically with loop
2D array battleship
Battleships - guys please help me out!