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. List<String> pe = new ArrayList<String>();
  13.  
  14. boolean resultado = pe.stream().anyMatch(t->t.equals("mama"));
  15. System.out.println(resultado);
  16. pe.add("mama");
  17. pe.add("meme");
  18.  
  19. resultado = pe.stream().anyMatch(t->t.equals("mama"));
  20. System.out.println(resultado);
  21.  
  22.  
  23. System.out.println(pe);
  24. Optional<String> test = pe.stream().findFirst();
  25.  
  26. if(test.isPresent()){
  27. System.out.println(test.get());
  28. }
  29. String post = test.get();
  30. System.out.println(post);
  31.  
  32. }
  33. }
Success #stdin #stdout 0.11s 48552KB
stdin
Standard input is empty
stdout
false
true
[mama, meme]
mama
mama