how to shuffle a string code example
Example 1: how to shuffle the elements in a string python
import random
Example 2: how to shuffle string java
public static String shuffleString(String string)
{
List<String> letters = Arrays.asList(string.split(""));
Collections.shuffle(letters);
String shuffled = "";
for (String letter : letters) {
shuffled += letter;
}
return shuffled;
}