Hey! I know that there is a method for arrays sort() that sorts an array. But is there also something like shuffle()? Say I have this code: String st = "a b c"; String[] ar = st.split(" "); Now what if I want to print each letter only one randomly?
2/11/2019 1:10:15 PM
Gino ^^3 Answers
New AnswerYou can look at the .shuffle method of Collections. It could be just what you need. https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#shuffle(java.util.List) G4G: https://www.geeksforgeeks.org/collections-shuffle-java-examples/
Hatsy Rei Cool thank you! But do I have to convert it into a list or can I also do it with a String Array
Learn Playing. Play Learning
SoloLearn Inc.
Send us a message