fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void allCombinations(String s, int i){
  11. if (i < s.length()){
  12. // Make a recursive call without removing
  13. allCombinations(s, i + 1);
  14.  
  15. if (s.charAt(i) == '%'){
  16. // Remove character at index i
  17. String temp = s.substring(0, i) + s.substring(i + 1);
  18. allCombinations(temp, i);
  19. }
  20. }
  21. else{
  22. System.out.println(s);
  23. }
  24. }
  25. public static void main (String[] args) throws java.lang.Exception
  26. {
  27. allCombinations("AA%0%0%", 0);
  28. }
  29. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
AA%0%0%
AA%0%0
AA%00%
AA%00
AA0%0%
AA0%0
AA00%
AA00