79557699

Date: 2025-04-06 01:19:18
Score: 0.5
Natty:
Report link

In Intellij Idea, add jdk24

enter image description here

enter image description here

Select Language Level SDK Default
enter image description here

Test code: you need to compile the class file before running with Java 24 if it's a diff. version.

public static void main(String[] args) {

    List<String> countrie = List.of("US", "India","China", "Japan","Australia", "Swiss");
    List<List<String>> windows = gatherIntoWindows(countrie);

    System.out.println("windows : " + windows);
}

public static List<List<String>> gatherIntoWindows(List<String> countries) {
    List<List<String>> windows = countries
            .stream()
            .gather(Gatherers.windowSliding(3))
            .toList();

    return windows;
}

output:
windows : [[US, India, china], [India, china, Japan], [china, Japan, Australia], [Japan, Australia, Swiss]]

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Vijay