Results 1 to 2 of 2
  1. #1
    aquafoam is offline Member
    Join Date
    Apr 2010
    Posts
    2
    Rep Power
    0

    Post StringList character rotation

    Please please help! I would appreciate it so much :)

    I'm trying to get a StringList of all the rotations for a given string, such as abcd

    ie. abcd -> bcda -> cdab -> dabc

    but I only seem to be able to get one with my code

    public static String iterations(String s) {
    StringBuffer iteration = new StringBuffer(butFirst(s));
    iteration.append(first(s));
    return iteration.toString();
    }

    the two methods

    first(s) gives the first letter of the string, ie. a of abcd
    butFirst(s) gives the rest of the string, ie. bcd of abcd

    could someone please help me get a list of all the rotations? I tried using a for loop but it doesn't seem to work...
    Last edited by aquafoam; 04-20-2010 at 05:12 AM.

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Quote Originally Posted by aquafoam View Post
    snip

    I tried using a for loop but it doesn't seem to work...
    Post your attempt, post the output you got, post the exact error messages you got.

    You need some kind of loop to get all rotations.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Image Rotation
    By mix99 in forum AWT / Swing
    Replies: 1
    Last Post: 02-24-2010, 10:25 AM
  2. Need help with 2d Array rotation!
    By TrungTran in forum Advanced Java
    Replies: 1
    Last Post: 11-23-2008, 05:35 AM
  3. Log rotation in ubuntu
    By sarah11 in forum New To Java
    Replies: 0
    Last Post: 11-04-2008, 07:46 AM
  4. Rotation in java 3D
    By émilie- in forum Java Applets
    Replies: 0
    Last Post: 02-13-2008, 10:37 AM
  5. affineTransform rotation
    By MichYer in forum AWT / Swing
    Replies: 0
    Last Post: 07-18-2007, 08:55 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
  •