fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.stream.*;
  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> values = new ArrayList<>();
  13. values.add("1000");
  14. values.add("10001111");
  15. values.add("45678901");
  16. values.add("1111");
  17. values.add("22222222");
  18. values.add("2222");
  19. values.add("33333333");
  20. List<Integer> indexes = values.stream().filter(s->s.length()==4).map(values::indexOf).collect(Collectors.toList());
  21. System.out.println(indexes);
  22. }
  23. }
Success #stdin #stdout 0.2s 33920KB
stdin
Standard input is empty
stdout
[0, 3, 5]