Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
String of arrays
tavo alfonso
Greenhorn
Posts: 7
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
what is the easy way to move one position the
string
of an array i mean.
array[0]=a;
array[1]=b;
array[2]=c;
so i have
abc
what i want to do is something like these
abc
bca
cab
just move one space the array
Michael Dunn
Ranch Hand
Posts: 4632
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
something like this (maybe??)
class Testing { public static void main(String[] args) { String[] array = {"a","b","c"}; for(int x = 0, y = array.length; x < y; x++) { for(int z = 0, zz = array.length; z < zz; z++) { System.out.print(array[(x+z)%zz]); } System.out.println(); } } }
Mateus Lucio
Ranch Hand
Posts: 60
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Use another variable to hold the value, while you switch the others characters, like bubblesort(if you know this one!)
Studying ...
Burkhard Hassel
Ranch Hand
Posts: 1274
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Tavo,
don't use an array. Use a java.util.LinkedList.
Then you just move it by saying:
Object moved = linkedListName.removeFirst();
linkedListName.offer(moved);
will move an element from the head of the list to its tail.
Yours,
Bu.
all events occur in real time
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
permutations
Printing out the combinations of a given string
Printing all string combinations
Programming Diversion 1
All possible combinations of the elements in the string array
More...