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. import java.time.DayOfWeek;
  8. import java.time.format.TextStyle;
  9. import java.util.Locale;
  10. import java.util.Optional;
  11.  
  12. /* Name of the class has to be "Main" only if the class is public. */
  13. class Ideone
  14. {
  15. public Optional < DayOfWeek > getFavoriteDayOfWeek ( )
  16. {
  17. return Optional.ofNullable( DayOfWeek.WEDNESDAY );
  18. }
  19.  
  20. public void demo()
  21. {
  22. this.getFavoriteDayOfWeek().ifPresent(
  23. ( DayOfWeek dayOfWeek ) -> {
  24. // Print, or whatever I wanna do!
  25. System.out.println( dayOfWeek.getDisplayName( TextStyle.FULL , Locale.CANADA_FRENCH ) );
  26. }
  27. );
  28. }
  29.  
  30. public static void main (String[] args) throws java.lang.Exception
  31. {
  32. Ideone app = new Ideone() ;
  33. app.demo() ;
  34. }
  35. }
Success #stdin #stdout 0.16s 36960KB
stdin
Standard input is empty
stdout
mercredi