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 main (String[] args) throws java.lang.Exception
  11. {
  12. // https://stackoverflow.com/questions/45912748/how-to-remove-multiple-characters-by-their-indice-from-a-string-in-java#45912835
  13. String test = "0123456789";
  14. int[] removingIndice = new int[] {2, 4, 0};
  15.  
  16. StringBuilder sb = new StringBuilder();
  17. loop:
  18. for (int i = 0; i < test.length(); i++) {
  19. for (int j = 0; j < removingIndice.length; j++) {
  20. if (i == removingIndice[j]) continue loop;
  21. }
  22. sb.append(test.charAt(i));
  23. }
  24.  
  25. System.out.println(sb);
  26. }
  27. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
1356789