Results 1 to 2 of 2
  1. #1
    wfsteadman is offline Member
    Join Date
    Jan 2013
    Location
    Texas
    Posts
    45
    Rep Power
    0

    Default Very simple question about creating a string line

    Good morning all,
    I have no idea why I can't find the answer, I am probably searching wrong or something but I want to have a line printed out to create a line of *
    so for example: I want a line with 25 * in it.

    *************************

    And for the life of me I can't remember the syntax

    String "*" x 25

    I can do it with a for loop, but was trying to see if there was a more efficient way.

    I have never done it in Java. I have done it in perl and python but not java.

    Please help this old guy who's mind is apparently drawing a blank.

    Thanks
    Wally

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default Re: Very simple question about creating a string line

    Java doen't have such shortcut syntax; you have to use a StringBuilder and a simple for-loop; the API documentation tells you the details.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Creating a new line
    By Huskies in forum New To Java
    Replies: 7
    Last Post: 08-06-2011, 07:49 AM
  2. Cant compile this simple line!
    By Pojahn_M in forum New To Java
    Replies: 2
    Last Post: 07-28-2011, 06:35 PM
  3. Replies: 6
    Last Post: 02-17-2011, 01:22 PM
  4. 30 line simple gui, simple error, need help
    By cc11rocks in forum New To Java
    Replies: 6
    Last Post: 02-05-2011, 08:33 PM
  5. Replies: 2
    Last Post: 07-02-2010, 02:20 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
  •