Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-28-2008, 01:23 AM
Member
 
Join Date: Nov 2007
Posts: 12
bluegreen7hi is on a distinguished road
Array Help
Hi, I have an assignment to make a console-based Tic Tac Toe game in Java. I first need to create an array of positions, from position 0 to 9. I'm familiar with arrays somewhat, but what I don't know is how to make it output my array in the form of the Tic Tac Toe matrix, like this:

0 1 2

3 4 5

6 7 8


I've been looking all over and I can't find any tutorials on how to make it output like this. I know it's something stupid and simple that I'm missing, but I can't seem to figure it out. Thanks in advance.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-28-2008, 01:52 AM
Member
 
Join Date: Mar 2008
Posts: 2
frea is on a distinguished road
i don't know java at all, but in pseudocode it would be

Code:
for i = 1 to 10 do print ( i - 1 ); if i mod 3 == 0 then print( newline );
mod -> modulo operator.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-28-2008, 04:25 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,402
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
In Java it's look like this.

Code:
for( int i = 0; i < 9; i++ ){ System.out.print(i + " "); if( i % 3 == 2 ){ System.out.println(); } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
can anyone help... 2d Array Mark1989 New To Java 2 03-12-2008 10:59 PM
Would appreciate your help with 2d Array.. cloudkicker New To Java 1 02-11-2008 04:34 PM
2D array bluekswing New To Java 2 01-15-2008 07:57 PM
Bounded Array bugger New To Java 4 01-04-2008 11:41 AM
Help with Array susan New To Java 1 08-07-2007 06:32 AM


All times are GMT +3. The time now is 05:12 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org