Java Stream Api

import java.util.*;

class StreamApiExample {
    public static void main(String[] args) {

        List<Integer> nums = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));
        System.out.println(nums);

        List<Integer> arr_nums = nums.stream().map(x -> x * x).toList();
        System.out.println(arr_nums);


        //With Multithreading - this will split and run in parallel cores
        List<Integer> cube_nums = nums.parallelStream().map(x -> x * x * x).toList();
        System.out.println(cube_nums);


        List<Integer> even_nums = nums.stream().filter(x -> x % 2 == 0).toList();
        System.out.println(even_nums);


        int sum_of_nums = nums.stream().reduce((t, x) -> t + x).orElse(0);
        System.out.println(sum_of_nums);

    }
}

19 Replies to “Java Stream Api”

  1. Hi, I do believe this is an excellent web site. I stumbledupon it 😉 I am going to revisit once again since I book-marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.

  2. I’ll immediately seize your rss feed as I can not find your e-mail subscription link or newsletter service. Do you’ve any? Please permit me know so that I may subscribe. Thanks.

  3. I’ll right away clutch your rss as I can’t in finding your email subscription hyperlink or newsletter service. Do you have any? Please permit me understand so that I may subscribe. Thanks.

  4. I will right away grab your rss feed as I can’t find your e-mail subscription hyperlink or newsletter service. Do you’ve any? Please permit me recognize in order that I may subscribe. Thanks.

  5. Howdy! Someone in my Myspace group shared this site with us so I came to look it over. I’m definitely enjoying the information. I’m book-marking and will be tweeting this to my followers! Wonderful blog and amazing design.

  6. For those seeking an exceptional online gaming experience, [maxispin.us.com](https://maxispin.us.com/) stands out as a premier destination. At Maxispin Casino, players can enjoy a vast array of pokies, table games, and other thrilling options, all accessible in both demo and real-money modes. The casino offers attractive bonuses, including free spins and a generous welcome offer, along with cashback promotions and engaging tournaments. To ensure a seamless experience, Maxispin provides various payment methods, efficient withdrawal processes, and reliable customer support through live chat. Security is a top priority, with robust safety measures and a strong focus on responsible gambling tools. Players can easily navigate the site, with detailed guides on account creation, verification, and payment methods. Whether you’re interested in high RTP slots, hold and win pokies, or the latest slot releases, Maxispin Casino delivers a user-friendly and secure platform. Explore their terms and conditions, read reviews, and discover why many consider Maxispin a legitimate and trustworthy choice in Australia.
    Both seasoned copywriters and beginners can find the resources they need on MaxiSpin.us.com to elevate their content.

    **Features of MaxiSpin.us.com**
    MaxiSpin.us.com boasts the ability to generate content in multiple languages as one of its key features.

    **Benefits of Using MaxiSpin.us.com**
    The scalability of the platform ensures it can cater to users of all sizes and industries.

  7. Discover the thrill of real-money live casino action at [url=https://maxispin-au.com/]casino card games[/url], where you can enjoy live dealers, top software providers, and exclusive promotions.
    Frequent updates ensure maxispin-au.com stays current with technology and user input.

  8. Sprawdz poradnik [url=https://jaka-kamera-do-drona-fpv.neocities.org/]jaka kamere do drona fpv wybrac[/url], jesli szukasz najlepszych wskazowek przy wyborze kamery FPV na start.
    Regularne przeglady i aktualizowanie oprogramowania wydluza zywotnosc i poprawia funkcjonowanie kamery.

Leave a Reply to sildenafil over the counter Cancel reply

Your email address will not be published.