Collections Refueled by Stuart Marks

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

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

  • @SourabhBhat
    @SourabhBhat 7 лет назад +1

    A very nice and concise presentation!! Thanks.

  • @kokavamsikrishna3933
    @kokavamsikrishna3933 5 лет назад +1

    Awesome, thanks Stuart mark's,

  • @SirWolf2018
    @SirWolf2018 7 лет назад +1

    For the "remove(str, i)" example at 18:58, "k" is a typo, correct is: "str", also, ""v" is a typo, correct is: "i".
    And then for even more understandability, rename "k1" and 'x' above to "k".

  • @AlanDarkworld
    @AlanDarkworld 7 лет назад +1

    Will there be a variant of "List.of(...)" that provides a regular, mutable ArrayList? Immutability is nice and dandy, but sometimes you just want a plain old list. Or will I have to stick with Guava's "Lists.newArrayList()"?

    • @Omega3131
      @Omega3131 7 лет назад

      Looks like there's no mutable equivalent according to the API.

    • @drewcaster
      @drewcaster 7 лет назад

      Arrays.asList(...) or Stream.of(...) or Arrays.stream(...)

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

      @@drewcaster Arrays.asList returns an immutable List! You need new ArrayList(Arrays.asList(T... args)) if you actually need a regular mutable ArrayList (without streaming) as OP asked.

  • @FenrirTheGray
    @FenrirTheGray 7 лет назад +2

    The Hodor stickers xD

  • @ipuluforu
    @ipuluforu 7 лет назад +1

    Hi, referring the video at 9:33 I tried the below code.
    List list = Arrays.asList(1,2,3,4,5,6,7,8,9,10);
    list.removeIf(n -> n==2);
    However it resulted in the below error.
    Exception in thread "main" java.lang.UnsupportedOperationException
    at java.util.AbstractList.remove(AbstractList.java:161)
    at java.util.AbstractList$Itr.remove(AbstractList.java:374)
    at java.util.Collection.removeIf(Collection.java:415)
    Can anyone please tell me what I missed actually?

    • @FrancoisGreen
      @FrancoisGreen 7 лет назад +1

      Here is an answer on Stack Overflow.
      stackoverflow.com/questions/7885573/remove-on-list-created-by-arrays-aslist-throws-unsupportedoperationexception

    • @ipuluforu
      @ipuluforu 7 лет назад

      Cool.... Thanks Francois Green

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

    15:25 Mark makes a small mistake calling it a BiFunction. The foreach actually takes a BiConsumer. That is, consumes two arguments and returns nothing.