Respuesta :
Answer: You can use this code for doing that.
public static void main (String[] args) throws java.lang.Exception {
String myString = "Something";
for(int i = 0; i < s.length(); i++){
myString = shift(myString);
System.out.println(myString);
}
}
/**Method string for the cycle
public static String shift(String s) {
return s.charAt(s.length()-1)+s.substring(0, s.length()-1);
}
Explanation: The method "shift" is the key. It returns a string, and the code line into it does the following:
return s.charAt(s.length()-1) : "cuts" the last character of the myString value.
Then concatenating (+) with
s.substring(0, s.length()-1) : creates a substring with the "rest" of the string.
The for loop repeats the process, assigning the method result to the value "myString" again and again, until it reaches the string length.
The output:
Something
gSomethin
ngSomethi
ingSometh
hingSomet
thingSome
ethingSom
methingSo
omethingS
Something
Hope it helps!