fork(1) 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. List<String> words = new ArrayList<>();
  13.  
  14. words.add("Kane");
  15. words.add("Cane");
  16. words.add("Fame");
  17. words.add("Dame");
  18. words.add("Lame");
  19. words.add("Same");
  20.  
  21. marklength4(words);
  22.  
  23. System.out.println(words);
  24. }
  25.  
  26. public static void marklength4(List<String> themarklength){
  27. List<String> values = new ArrayList<String>(themarklength);
  28. int inserted = 0;
  29. for (int index = 0; index < values.size(); index++) {
  30. String value = themarklength.get(index);
  31. if (value.length() == 4) {
  32. themarklength.add(index + inserted++, "****");
  33. }
  34. }
  35. }
  36. }
Success #stdin #stdout 0.06s 380160KB
stdin
Standard input is empty
stdout
[****, Kane, ****, Cane, ****, Fame, ****, Dame, ****, Lame, ****, Same]