Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void permutate(ArrayList<String> a){
- //create a combined string of the array list
- String tempStr = "";
- for(int i = 0; i < a.size(); i++){
- tempStr = tempStr + a.get(i);
- }
- doThings("",tempStr);
- }
- public static void doThings(String str1, String str2){
- //do all of the things to the other things at the time with the stuff
- if (str2.length() <= 1)
- System.out.println(str1 + str2);
- else
- for (int i = 0; i < str2.length(); i++) {
- String tempStr = str2.substring(0, i) + str2.substring(i + 1);
- doThings(str1 + str2.charAt(i), tempStr);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment