Java Streams Part 3 - Map Method | Mapping Collection by using Stream | Hands-On

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

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

  • @ibrahimhamid2981
    @ibrahimhamid2981 3 года назад +10

    Honestly, I have never commented on a video before on youtube but for this I cannot hold my peace than to Thank you for this wonderful videos. You have my 5 stars already. I really really love this

  • @Hari_Goud
    @Hari_Goud Год назад +3

    map(Function

  • @sudarshanar4165
    @sudarshanar4165 3 года назад +19

    11.24 - it seems ,map will take Function as parameter, not Consumer

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

    forEach(Consumer

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

    Fantastic Explanation in Java 8 i saw all udemy and youtubue channel this is one fantastic explanation and eazily understand once study.

  • @funvideos3984
    @funvideos3984 4 года назад +1

    You are Awesome.....Best Teaching for each and every topic...Thank you so much

    • @sdetpavan
      @sdetpavan  4 года назад +1

      You are most welcome

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

    The best so far

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

    Last few minutes of video ,I think that you should have performed some operation inside map but you simple printed it ,but thank you

  • @TheMorningLotus
    @TheMorningLotus 8 месяцев назад +1

    Great video. Thanks for uploading it. ❤

    • @sdetpavan
      @sdetpavan  8 месяцев назад

      Glad you enjoyed it!

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

    Thanks for this video. It's helpful.

  • @karuppaiyansubashchandrabo9337
    @karuppaiyansubashchandrabo9337 4 года назад

    The video explains the concept in more understandable form than any other articles in recent past. Yet I would like to know how Streams and the methods are internally working. Is Java really implementing some optimized logic better regular coding or compiler writing regular code internally on behalf us, just for reducing the redundant code?. IS Stream really faster than regular approach?

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

    Hi Sir,
    I want to correct two things. your way of teaching is nice.
    1. map-> It takes function as argument Returns a stream consisting of the results of applying the given function to the elements of this stream.
    2. In this program there is no need of map(). we can do directly using filter only.
    employeeList.stream().filter(e->e.getSalary()>20000).forEach(e->System.out.println(e.getSalary()));
    Output-
    30000
    40000
    50000
    Kindly look into it.

    • @madhavikatta7346
      @madhavikatta7346 4 месяца назад

      Hi
      Actually sir wants to store in another list. So we should use map to store and print the list of salary

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

    Thanks for another wonderful video!

  • @padminil2315
    @padminil2315 8 месяцев назад +1

    Excellent 👌

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

    Nice explanation sir

  • @hussainiabdulmuminu8355
    @hussainiabdulmuminu8355 4 года назад +1

    Best tutorial always!

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

    Excellent explanation!

  • @poojasharma-cc5ur
    @poojasharma-cc5ur 2 месяца назад

    Question were very very basic pls try to add a bit complex Qs after 1,2 regular Qs. Because in interviews we were not asked this much basic QS

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

    Thanks for this video. It's helpful. Is Map and Foreach methods are same?. Because I see both of them can be used to print the list objects

    • @charanreddy9357
      @charanreddy9357 11 месяцев назад

      no u are wrong

    • @charanreddy9357
      @charanreddy9357 11 месяцев назад

      map is taking function as a parameter and the return object of function is added to stream. at the end it will return that stream

    • @sapthasagar7840
      @sapthasagar7840 9 месяцев назад

      no bro, foreach uses consumer class and accepts the stream and performs operation, it does not return anything if you check documentation of foreach its return type would be null, other hand map returns a stream, which we can do something like printing, or converting a list, in simple words foreach takes a stream and just performs the operation does not return anything (it uses concept of functional interface and lambda expression check in youtube ), but map takes a function as parameter and performs that function on the elements in the stream and returns a new stream.

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

    Thank you Sir.

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

      You are most welcome

  • @preetamvarun9219
    @preetamvarun9219 11 месяцев назад +1

    Thank you

  • @sambhasin4
    @sambhasin4 4 года назад

    Nice Content.

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

    Is there video on Optional class java 8 feature ?

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

    Everything is good sir
    Bt one doubt
    What if I want to save the modified employee list instead of list

    • @sapthasagar7840
      @sapthasagar7840 9 месяцев назад

      you can create a List and then after you apply map or filter the result you can save to this list with collect(Collectors.toList()), it would be like this
      lets say you have employee class with name and ID , and you have a list of objects of type Employee,
      //creating employee class
      class Employee{
      int Id;
      String name;
      Employee(int Id,String name){
      this.Id=Id;
      this.name=name;
      }
      }
      //creating main class with filter implementation
      public class MapInStreamsPractice {
      public static void main(String[] args) {
      //creating list of employee class
      List employees = new ArrayList();
      employees.add(new Employee(21,"rajesh"));
      employees.add(new Employee(22,"shiva"));
      employees.add(new Employee(23,"vignesh"));
      //filtering each employee whos id is greater than 20 using filter method.
      List employeeList=employees.stream().filter(employee -> employee.Id>20).collect(Collectors.toList());
      //you can print employeelist and check for output
      }
      }

  • @Sciencehope104
    @Sciencehope104 9 месяцев назад

    We can add list in the collection

  • @alpeshmarchande3706
    @alpeshmarchande3706 4 года назад

    Thanks Sir... Please make videos on dot net.

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

    Hi Sir can ou help me out in this logic?
    Create Person class that contains first name, last name, and ID.
    - Create a getCommonLastNames() method with that takes List as a parameter.
    - The method should return a Map
    whereby the key is the common last name and the value is the list of firstnames of people that share the same last name.
    i can do this...
    Map Map8 = Person1.stream().collect(Collectors.toMap(Person::getFirstName, Person::getLastName));
    Map Map8 = Person1.stream().filter(f->f.FirstName==f.LastName).collect(Collectors.toMap(Person::getFirstName, Person::getLastName));

  • @rameshdharnasi7421
    @rameshdharnasi7421 4 года назад

    Send keys functionality not working in my appium program.how to send the data into text field

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

    Hi sir, after filtering based on Salary, i want to update the salary by increasing 10 percent and return complete employe objects, how can i achieve this

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

      employeesList.stream()
      .filter(emp -> emp.salary > 25000)
      .map(emp -> {
      emp.salary = emp.salary + (emp.salary * 10) / 100;
      return emp;
      })
      .forEach(t -> System.out.println(t));

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

      employeesList.stream().filter(emp->emp.salary>50000 && emp.salary{
      emp.salary += emp.salary*0.1;
      return emp;
      })
      .forEach(System.out::println);