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)
  11. {
  12.  
  13. String[] test = {"this", "is", "the", "example", "of", "the", "call"};
  14. String[] result = removeFromArray(test, "the");
  15. System.out.println(Arrays.toString(result));
  16. }
  17.  
  18. public static String[] removeFromArray(String[] arr, String toRemove)
  19. {
  20. List<String> resultList = new ArrayList<String>();
  21. for(int i = 0; i < arr.length; i++)
  22. {
  23. if(!arr[i].contains(toRemove))
  24. {
  25. resultList.add(arr[i]);
  26. }
  27. }
  28. return resultList.toArray(new String[resultList.size()]);
  29. }
  30. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
[this, is, example, of, call]