0

Could any of you guy tell me how to get a list of random orders of the given string in java?

25th Mar 2023, 5:23 AM
Killiam Chances
Killiam Chances - avatar
9 Réponses
+ 2
Your question is unclear. Can you give an example of the input and expected output?
25th Mar 2023, 6:01 AM
Tibor Santa
Tibor Santa - avatar
+ 2
I think I got it and I really appreciate each of your answers thanks you all
25th Mar 2023, 12:20 PM
Killiam Chances
Killiam Chances - avatar
+ 1
For example,if your input is "ABC",I want to get a list of possible orders like "CBA","ACB","CAB",etc.....
25th Mar 2023, 9:56 AM
Killiam Chances
Killiam Chances - avatar
25th Mar 2023, 10:01 AM
Just Some Random Guy
Just Some Random Guy - avatar
+ 1
Okay
25th Mar 2023, 10:30 AM
Otid Kartgepsut
Otid Kartgepsut - avatar
0
Killiam Chances Do you mean to randomly arrange elements of a list?
25th Mar 2023, 6:33 AM
Just Some Random Guy
Just Some Random Guy - avatar
0
Yes, one way to get a list of random orders of a given string in Java is to convert the string to a list of characters, shuffle the list using the `Collections.shuffle()` method, and then convert the list back to a string. Here is an example: ``` import java.util.ArrayList; import java.util.Collections; import java.util.List; public class StringRandomizer { public static void main(String[] args) { String inputString = "example"; List<Character> charList = new ArrayList<>(); for (char c : inputString.toCharArray()) { charList.add(c); } Collections.shuffle(charList); StringBuilder sb = new StringBuilder(); for (char c : charList) { sb.append(c); } String outputString = sb.toString(); System.out.println(outputString); } } ``` In this example, we first convert the input string to a list of characters, shuffle the list using `Collections.shuffle()`, and then convert the shuffl
25th Mar 2023, 6:58 AM
Otid Kartgepsut
Otid Kartgepsut - avatar
25th Mar 2023, 9:59 AM
Otid Kartgepsut
Otid Kartgepsut - avatar
0
You can used random function?
25th Mar 2023, 2:01 PM
Aurang Zeb
Aurang Zeb - avatar