I am doing something simple and cannot figure out how to do it.
I have an ArrayList which I used the stream().map() method on and I want to immediately add the results to a new ArrayList.
    List<Integer> list = new ArrayList<>();
    Scanner sc = new Scanner(System.in);
    while (list.size() < 5) {
        System.out.println("Enter numbers of the array : ");
        int num = sc.nextInt();
        list.add(num);
    }
    System.out.print("Before mapping : ");
    list.forEach(a -> System.out.print(a + " "));
    System.out.println("");
    System.out.print("After mapping : ");
    List<Integer> mappedList = new ArrayList<>();
    list.stream().map(n -> n * 3);
    mappedList.forEach(a -> System.out.print(a + " "));
So I want to do something like mappedList = list.stream().map(n -> n * 3);
But that is not the right way to do it.
PS advice on any other section of my code would be appreciated too. Thanks!
 
     
     
    