Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By SurfMan

Thread: Creating a Square

  1. #1
    cheerio is offline Member
    Join Date
    May 2014
    Posts
    1
    Rep Power
    0

    Default Creating a Square

    Hi guys! I much very much interested in learning Java and though I do not have any background in programming whatsoever, I really, really wanted to try it. With that being said, it would be very much appreciated if anyone can help me figure out why I can't seem to get this program right. I aim to create a solid square using this:


    public class asteriskSquare {

    public static void main(String[] args) {

    for (int x = 1; x <= 4; x++){
    for (int y = 1; y <= 4; y++){
    System.out.println("+");
    }
    System.out.println("+");
    }
    }

    }



    Sadly, all I'm getting is a single column of "+".
    Thanks in advance guys!

  2. #2
    SurfMan's Avatar
    SurfMan is online now Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,080
    Rep Power
    4

    Default Re: Creating a Square

    println ends the output with a new line, so ALL asterisks are followed by a newline. Instead, use a combination of print() and println().
    R03 likes this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. Replies: 2
    Last Post: 03-23-2012, 05:53 AM
  2. Need Help with Magic Square
    By easybe in forum New To Java
    Replies: 10
    Last Post: 04-23-2010, 10:39 PM
  3. Magic Square!!!... :D
    By joms999 in forum New To Java
    Replies: 4
    Last Post: 02-25-2010, 08:55 AM
  4. How can I square(^2) the pic in the grid
    By racewithferrari in forum New To Java
    Replies: 1
    Last Post: 11-01-2009, 11:16 PM
  5. Creating a New Method for Square Root Loop
    By SapphireSpark in forum New To Java
    Replies: 14
    Last Post: 02-25-2009, 02:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •