/* package whatever; // don't place package name! */ import java.util.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { printPermutations(s, ""); } if(s == null || s.length() == 0){ return; } for(int k=0; k<s.length(); k++){ printPermutations(s.substring(0,k)+s.substring(k+1), target); } } }