Well I'm supposed to print all possible combinations of a given word(I'm writing this for the benefit of those who might not have guessed this from the subject). I've got some code but its horribly wrong. Could anyone point out any mistakes.
public class Try
{
public void display(String s)
{
char ch[]=s.toCharArray();
for(int i=0;i<ch.length;i++)
{
String word="";
word+=ch;
char c[]=new char[s.length()];
for(int j=0;j<ch.length;j++)
{
if(ch[j]!=ch[i])
c[j]=ch[j];
}
for(int j=0;j<ch.length;j++)
{
for(int k=0;k<ch.length;k++)
{
if(c[j]!=c[k])
word+=c[k];
}
word+=c[j];
System.out.println(word);
}
}
}
}