import java.util.ArrayList; import java.util.Scanner; // Java Program to find all permutations of a String public class StringPermutation { public static ArrayList permutationFinder(String str) { ArrayList perm = new ArrayList(); Handling error scenarios if (str == null) { return null; } else if (str.length() == 0) { perm.add(""); return perm; } char initial = str.charAt(0); first character String rem = str.substring(1); Full string without first character ArrayList words = permutationFinder(rem); for (String strNew : words) { for (int i = 0; i
Enter your a String: abc Permutations for abc are: [abc, bac, bca, acb, cab, cba]