Results 1 to 4 of 4
  1. #1
    ustar is offline Member
    Join Date
    Feb 2010
    Posts
    7
    Rep Power
    0

    Unhappy Repeat a letter twice in java.

    Hi In need to write a program that repeats a letter twice.
    For example the word the car. I would like the program to repeat with word a. ----------------So the output comes out to be caar.-----------------------

    Does anyone know what method I can use?

    All I have so far is:

    public class Words
    {
    /**
    Computes a string that repeats every letter 'a' in the original string.
    @param s any string
    @return a string with the same characters as s, except that every letter 'a' is repeated
    */
    public String stutter(String s)
    {







    }
    }

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What have you tried?
    Read the API specs for String class to see the available methods and pick the one that you think best solves the problem.

  3. #3
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by r035198x View Post
    Read the API specs for String class to see the available methods and pick the one that you think best solves the problem.

    do you mean for example charAt() :p

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by j2me64 View Post
    do you mean for example charAt() :p
    Another example is toCharArray.

Similar Threads

  1. Help with a repeat
    By leeavital in forum New To Java
    Replies: 1
    Last Post: 01-01-2010, 09:42 PM
  2. Go-back-N & Selective repeat protocol
    By Engineera in forum Networking
    Replies: 3
    Last Post: 01-14-2009, 11:18 PM
  3. Repeat while answer yes - do while loop
    By AJ2009 in forum New To Java
    Replies: 1
    Last Post: 01-10-2009, 06:19 PM
  4. Replies: 1
    Last Post: 07-02-2008, 02:15 PM
  5. nested <ui:repeat> - problem
    By hackerofcrackers in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 06-20-2008, 10:06 AM

Posting Permissions

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