GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Strign of arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Strign of arrays" Watch "Strign of arrays" New topic
Author

Strign of arrays

tavo alfonso
Greenhorn

Joined: Nov 02, 2006
Posts: 7
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

Joined: Jun 09, 2003
Posts: 4632
something like this (maybe??)

Mateus Lucio
Ranch Hand

Joined: Jul 27, 2006
Posts: 57
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

Joined: Aug 25, 2006
Posts: 1274
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Strign of arrays