Results 1 to 2 of 2
Thread: StringList character rotation
- 04-20-2010, 05:16 AM #1
Member
- Join Date
- Apr 2010
- Posts
- 2
- Rep Power
- 0
StringList character rotation
Please please help! I would appreciate it so much :) Sorry if I am posting in the wrong place, I just started... :)
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...
- 04-20-2010, 05:23 AM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Similar Threads
-
StringList rotation
By aquafoam in forum New To JavaReplies: 1Last Post: 04-20-2010, 08:02 AM -
Read from a certain character to a certain character
By blackstormattack in forum New To JavaReplies: 0Last Post: 03-16-2009, 11:36 AM -
Need help with 2d Array rotation!
By TrungTran in forum Advanced JavaReplies: 1Last Post: 11-23-2008, 05:35 AM -
Log rotation in ubuntu
By sarah11 in forum New To JavaReplies: 0Last Post: 11-04-2008, 07:46 AM -
reading text character by character
By bugger in forum New To JavaReplies: 2Last Post: 11-09-2007, 08:54 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks