How do I shuffle the characters in a string (e.g. hello could be ehlol or lleoh or ...). I don\'t want to use the Collections.shuffle(...) method, is there anyt
What an annoying problem. I finally ended up with this:
import java.util.Collections;
import com.google.common.primitives.Chars;
import org.apache.commons.lang3.StringUtils;
String shuffle(String s) {
List chars = Chars.asList(s.toCharArray());
Collections.shuffle(chars);
return StringUtils.join(chars.stream().toArray());
}
Yes, two libraries :)