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.* ;
  8. import java.time.format.* ;
  9. import java.time.temporal.* ;
  10. import java.time.chrono.* ;
  11.  
  12.  
  13. /* Name of the class has to be "Main" only if the class is public. */
  14. class Ideone
  15. {
  16. public static void main (String[] args) throws java.lang.Exception
  17. {
  18.  
  19. int year = 2020 ;
  20. long count =
  21. Arrays // Utility class, `java.util.Arrays`.
  22. .stream( // Generate a stream from an array.
  23. Month.values() // Generate an array from all the objects defined on this enum `Month`: An object for January, and February, and so on.
  24. ) // Returns a `Stream` object.
  25. .filter( // Applies a `Predicate` to test each object produced by the stream. Those that pass the test are fed into a new second stream.
  26. ( Month month ) -> // For each `Month` enum object.
  27. LocalDate // Represent a date-only value, a year-month-day.
  28. .of( year, month, 13 ) // Instantiate a `LocalDate` from inputs for year number, `Month` enum object, and day number.
  29. .getDayOfWeek() // Interrogate for the `DayOfWeek` enum object that represents the day-of-week for that particular date.
  30. .equals(DayOfWeek.FRIDAY)
  31. )
  32. .count()
  33. ;
  34.  
  35. System.out.println( "count: " + count ) ;
  36. }
  37. }
Success #stdin #stdout 0.11s 35320KB
stdin
Standard input is empty
stdout
count: 2