Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: looping through a string

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default looping through a string

    How do you loop through the String "COMMUNICATION" for example

    And give the String restrictions so it spaces each letter in the String and only has a specific amount of letters/spaces per line.

    C O
    M M
    U N
    ... etc

    Please ask questions if you don't understand what I'm asking for

    Thanks


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: looping through a string

    Sit down with and write out how you would do this. This is your algorithm. Then translate this to code. Use the API to guide and provide you methods you can use, for instance, String (Java Platform SE 6) When you lay down some code and have trouble, post with the code and a specific question

  3. #3
    Member
    Join Date
    Mar 2011
    Location
    Earth!
    Posts
    77
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: looping through a string

    Not sure I understand exactly what you mean, but if you want to loop through a string you can always use the chatAt or substring methods in a for loop or something. Just follow copegs link, it contains descriptions of all the methods in the string class.

Similar Threads

  1. Need help with looping!
    By crsoccerplayer6 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 29th, 2011, 04:09 PM
  2. Replies: 9
    Last Post: June 29th, 2011, 12:27 PM
  3. Help in looping
    By endframe in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 28th, 2010, 03:24 PM
  4. need help looping with a string
    By beandip408 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 29th, 2010, 09:08 AM
  5. [SOLVED] looping, for,while,do-while.
    By chronoz13 in forum Loops & Control Statements
    Replies: 4
    Last Post: August 6th, 2009, 01:32 PM