Java 8 Streams | map() and reduce() Example | JavaTechie

Поделиться
HTML-код
  • Опубликовано: 7 сен 2024
  • This tutorial will guide you to understand java 8 stream api map-reduce concept with Realtime implementation
    #javatechie #stream #java8
    GitHub:
    github.com/Jav...
    Blogs:
    / javatechie
    Facebook:
    / 919464521471923
    guys if you like this video please do subscribe now and press the bell icon to not miss any update from Java Techie
    Disclaimer/Policy:
    --------------------------------
    Note : All uploaded content in this channel is mine and its not copied from any community , you are free to use source code from above mentioned GitHub account

Комментарии • 77

  • @sanketprajakta
    @sanketprajakta 22 дня назад +1

    nice explanation with simple examples.

  • @Netalon
    @Netalon 3 года назад +9

    Very Nice content! Greetings from Brazil 🇧🇷

    • @Javatechie
      @Javatechie  3 года назад +2

      Glad to have viewers from Brazil

  • @qwarlockz8017
    @qwarlockz8017 2 года назад +2

    Thank you so much. I am finding your videos are the clearest I have seen on the subjects. It is truly a pleasure to learn from you.

  • @akjoker79
    @akjoker79 2 года назад +1

    The examples used are simple , crisp and. clear

  • @rishikesharora8681
    @rishikesharora8681 3 года назад +1

    i got out from the interview just because i could not tell the reduce method with map....Now i wont get out for this topic at least 😍
    at the end, its just a QUALITY CONTENT

  • @AkanshaGrowArts
    @AkanshaGrowArts Год назад +2

    Thanks for the nice video sir.

  • @muralikrishna6044
    @muralikrishna6044 10 месяцев назад +1

    I love the way of elocution.. Gohead..

  • @parthec1
    @parthec1 2 года назад +1

    Very informative video,thanks for creating it,,

  • @learningjavawithme915
    @learningjavawithme915 3 года назад +3

    As always you are excellent sir

  • @maheshd3506
    @maheshd3506 Год назад +1

    Thanks for your clear explanation

  • @rajeshchaurasia3609
    @rajeshchaurasia3609 3 года назад +2

    I enjoy all your videos. Excellent work sir

  • @pratishrutipanda6461
    @pratishrutipanda6461 3 года назад +2

    Nice video sir

  • @channabasavav1823
    @channabasavav1823 2 года назад +1

    Thank you Java Techie 🙏🙏

  • @LearnWithKhurshid
    @LearnWithKhurshid 3 года назад +1

    Nicely explain video 👍

  • @venkyyadav9527
    @venkyyadav9527 2 года назад +1

    Thank you so much. Your explanation always easy to understandable.

    • @Javatechie
      @Javatechie  2 года назад

      Keep learning buddy thank you 😊

  • @prakrutijani4205
    @prakrutijani4205 6 месяцев назад +1

    Your content fan thankyou

  • @jayw8946
    @jayw8946 3 года назад +1

    great vedio

  • @yogendrasingh-nz3pw
    @yogendrasingh-nz3pw 3 года назад +1

    nyc explanation

  • @nullpointer500
    @nullpointer500 2 года назад +1

    What a great tutorial

  • @aveshkadri
    @aveshkadri 3 года назад +1

    very helpful.

  • @amgadmohammed6358
    @amgadmohammed6358 3 года назад +1

    Wonderful

  • @josephnairpudupermanil8679
    @josephnairpudupermanil8679 2 года назад

    Nice explanation

  • @Srini8174
    @Srini8174 3 года назад +1

    Your content explanation always easy to understandable.Pls explain with explain on distributed transaction in micro services.

  • @gdIndia199
    @gdIndia199 2 года назад +1

    great

  • @francksgenlecroyant
    @francksgenlecroyant 2 года назад +1

    Well done buddy!

  • @kishordige9721
    @kishordige9721 Год назад +1

    Thank you!

  • @paileemallesh9942
    @paileemallesh9942 2 года назад +1

    Thank you

  • @ashfaqmohammad1086
    @ashfaqmohammad1086 5 месяцев назад

    What do you mean by more readable?
    In the summation example using iterative approach is also much more readable and verbose also, while in streams if some complex operation is being performed, you cannot debug the intermediate state until terminal operation is performed.
    Traditional approach can be understood by even grade 10 student if he has learnt any programming language, why do we call streams more readable?

    • @Javatechie
      @Javatechie  5 месяцев назад

      Hello buddy why can't you debug stream operations? Also when I say readable it means we do method chaining in such a way that it can easily identify what function we are performing in sequence

  • @suryaenjarapu
    @suryaenjarapu Год назад

    int result = numbers
    .stream()
    .reduce(0, (previousReturnedValue, element) -> previousReturnedValue + element);

  • @gasparcalix2095
    @gasparcalix2095 Год назад

    excelent!

  • @jenlopoz4990
    @jenlopoz4990 2 года назад

    subcriber from ph

  • @chetanbhandari3033
    @chetanbhandari3033 3 года назад +1

    Thanks basant wlc back..

  • @Mateo-cy7cc
    @Mateo-cy7cc Год назад

    Muchas gracias

  • @malleswarrao3887
    @malleswarrao3887 Год назад

    Can you please help out for small question:
    Q) How can i get top 3 longest words in a given string using java 8

  • @mirrabiluddin3798
    @mirrabiluddin3798 2 года назад +1

    Map while Customer Object contains two filed Type and coount .type=I,count=10 ,type=o,count=20 .I want to display another map which contains Map = .eg.Map,MAP and so on. plz help

    • @Javatechie
      @Javatechie  2 года назад

      Not clear please elaborate it

  • @sanjay26031983
    @sanjay26031983 2 года назад

    Example : input : { a, b, k, {A, c, G,H,p}}
    output : {a, b, k, {c,p}} . How to write stream fn for this. Expection is to remove capital letter from list.

  • @sreddy8141
    @sreddy8141 3 года назад +1

    Sir, we usually don't use getters seters explicitly mentioned right, like we go for lombok, if we have to have null check in getter methods , we can eliminate oly getter generation from lombok and have optional null check ? Or is there any way we have optimized way to do this?

    • @Javatechie
      @Javatechie  3 года назад

      Lombok is not recommended in prod environment

    • @sreddy8141
      @sreddy8141 3 года назад +1

      @@Javatechie thanks sir, i wasn't aware of this. Good to know this , will try to know the reason for it to have concrete details

  • @siddhantpatel4768
    @siddhantpatel4768 7 месяцев назад

    List names = Arrays.asList("mike", "java", "adam", "ram"); here what output i will be expect for longest string?

    • @Javatechie
      @Javatechie  7 месяцев назад

      Excellent , i believe it will print all since all words having 4 character

    • @siddhantpatel4768
      @siddhantpatel4768 7 месяцев назад

      @@Javatechie yeah ,but it is not possible with reduce method because it will give single output,so what are we do in such situations?.. also your content is lot of helpful for beginners 🙏

    • @Javatechie
      @Javatechie  7 месяцев назад

      We can use something like this
      import java.util.Arrays;
      import java.util.List;
      public class Main {
      public static void main(String[] args) {
      List stringList = Arrays.asList("Mike", "java");
      int maxLength = stringList.stream()
      .map(String::length)
      .max(Integer::compare)
      .orElse(0);
      stringList.stream()
      .filter(str -> str.length() == maxLength)
      .forEach(str -> System.out.println("Longest string: " + str));
      }
      }

  • @abanisahoo5926
    @abanisahoo5926 3 года назад +1

    Nicely explained!!!

  • @nareshe9906
    @nareshe9906 Год назад

    int arr1[] ={1,2,3,4,5}; when you define array as like this instead of Arrays.asList(1,2,3,4,5) how we can achieve iit ?

  • @anukratsoni3940
    @anukratsoni3940 3 года назад

    Can you please tell me how to find particular char or non-repeating in the string like ThatForThats I have to find ''F" in this

  • @sameepkaranjkar2263
    @sameepkaranjkar2263 2 года назад +1

    Hi ,
    Any particular reason for having .map(employee -> employee.getSalary()) step in below example ?
    double sumSalary = EmployeeDatabase.getEmployees().stream()
    .filter(employee -> employee.getGrade().equalsIgnoreCase("A"))
    .map(employee -> employee.getSalary())
    .mapToDouble(i -> i)
    .sum();
    We could also do it as :
    EmployeeDatabase.getEmployees().stream()
    .filter(employee -> employee.getGrade().equalsIgnoreCase("A"))
    .mapToDouble(employee->employee.getSalary())
    .sum();

    • @Javatechie
      @Javatechie  2 года назад +1

      Yes you are correct we can do that

  • @prashanthdhn5216
    @prashanthdhn5216 3 года назад +1

    Hi Grate Techie ,could please upload rest api and Hibernate Jpa videos..🙏

    • @Javatechie
      @Javatechie  3 года назад

      It's already there please go to my channel and on right top corner you can see search tab
      Just search with key which you want

  • @renejacques8288
    @renejacques8288 2 года назад

    Why isn't (a,b) -> a+b a bifunction since we have 2 parameters a and b?

  • @shre9172
    @shre9172 11 месяцев назад +2

    Why we have to use .get() method

  • @aadarshchowdary
    @aadarshchowdary 3 года назад +1

    Hi,what is the use of identity in reduce can you explain.You have used 0 in sum and 1 in multiplication.

    • @Javatechie
      @Javatechie  3 года назад

      Identity is just initial value .
      If you observed in iterative approach I took one variable i.e sum=0
      That is nothing your identity

    • @aadarshchowdary
      @aadarshchowdary 3 года назад +1

      @@Javatechie Thanks for the explanation.

  • @sureshmanne7245
    @sureshmanne7245 Год назад +1

    17:00 can we use 2 filters, one to get grade and 2nd one to get salary?

    • @Javatechie
      @Javatechie  Год назад +1

      Yes you can but why can't we add both conditions in a single filter

    • @sureshmanne7245
      @sureshmanne7245 Год назад

      @@Javatechie I tried but getting conversion error, let me try both conditions in one filter itself

  • @sanketh768
    @sanketh768 Год назад +1

    hello Sir,
    was very clear with the explanations, so the doubt is last 2 calculations using sum and average they did not use reduce function. Hence can they still be called as reductions?
    Like every terminator operations like max,min,count etc are called reductions?

    • @Javatechie
      @Javatechie  Год назад

      Yes they come under reduction

  • @sarojsahoo8763
    @sarojsahoo8763 3 года назад +1

    Does stream does parallel operation by default or we need to call parallel stream

    • @Javatechie
      @Javatechie  3 года назад +1

      No reduction method used parallel execution.
      We must need to use parallel stream for parallisim

  • @jayw8946
    @jayw8946 3 года назад

    Can you please make vedio on Intellij tricks tips

  • @devilscarrybach8672
    @devilscarrybach8672 2 года назад

    What is use of map when we can directly use mapToDouble

  • @sanketskhandekar
    @sanketskhandekar 3 года назад +1

    Nice do you have interview series

  • @__nitinkumar__
    @__nitinkumar__ 3 года назад

    how i->i means it an integer?
    Can you please explain this...?

  • @nick-sx2zn
    @nick-sx2zn 3 года назад

    Bro u have any videos related to method reference

  • @gayathrigayu9960
    @gayathrigayu9960 3 года назад

    Sir I want file merging using mapreduce in Java coding

  • @amitkumar-uj8wz
    @amitkumar-uj8wz 2 года назад +1

    sounds quality is not very good

    • @Javatechie
      @Javatechie  2 года назад

      Please try increasing your system volume once and let me know if still clarity is not good