I have to print all the possible permutations of the given input string.
Using the code below I get aaaa bbb ccc now in next iteration I want to print aaa aab aac. aba aca and so on. Please guide me about it.
String s = "abc";
char ch;
ArrayList<Character> input = new ArrayList<Character>();
public static void main (String [] args)
{
String s= "abc";
int count ;
char ch;
ArrayList<Character> input = new ArrayList<Character>();
for (int i=0; i < s.length(); i++)
{
ch = s.charAt(i);
input.add(ch);
}
for (int i=0; i <= input.size(); i++)
{
for(int j=0; j < input.size(); j++)
{
System.out.print(input.get(i));
}
System.out.println();
}
}
ArrayList<Character>to store String characters while every character can be read usings.charAt(i)?