can anyone tell me why it is showing compilation error?
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
String str = scn.next();
ArrayList<String> list = getP(str);
Collections.sort(list);
for (int i = 0; i < list.size(); i++) {
if (list.get(i).compareTo(str) < 0) {
System.out.println(list.get(i));
}
}
}
public static ArrayList<String> getP(String str) {
if (str.length() == 0) {
ArrayList<String> base = new ArrayList();
base.add("");
return base;
}
char cc = str.charAt(0);
String ros = str.substring(1);
ArrayList<String> myResult = new ArrayList();
ArrayList<String> recResult = getP(ros);
for (String s : recResult) {
// StringBuilder sb=new StringBuilder(s);
for (int j = 0; j <= s.length(); j++) {
// sb.insert(j, cc);
String val = s.substring(0, j) + cc + s.substring(j);
myResult.add(val);
}
}
return myResult;
}
}