Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8261865

Getting while NPE exception while using Collectors.toMap

    XMLWordPrintable

    Details

      Description

      ADDITIONAL SYSTEM INFORMATION :
      java.lang.NullPointerException

      A DESCRIPTION OF THE PROBLEM :
      List<Object[]> list = new ArrayList<>();

      Object[] ar = {123,null};
      Object[] arr = {321,null};
      list.add(ar);
      list.add(arr);

      Map<Integer, String> collect = list.stream()
      .filter(Objects::nonNull)
      .collect(Collectors.toMap(obj -> (Integer)obj[0], obj -> (String)obj[1]));

      System.out.println(collect);


        Attachments

          Activity

            People

            Assignee:
            psandoz Paul Sandoz
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: