Java 21 New Feature: Sequenced Collections - JEP Cafe #19

Поділитися
Вставка
  • Опубліковано 31 тра 2024
  • Learn the principles of the Sequenced Collections, Sets, and Maps, a new feature introduced in JDK 21.
    Sequenced Collections are about modelling collections with a defined encounter order, giving you direct access to their first and last element. Learn about the new Sequenced Collections API, part of the Collections Framework, introduced in JDK 21.
    ⎯⎯⎯⎯⎯⎯ Chapters ⎯⎯⎯⎯⎯⎯
    0:00 Intro
    1:19 Introducing the architecture of the Collections API
    2:38 What does it mean for a collection to be sorted
    3:46 Ordering elements in a collection with an index
    4:53 Differences between Lists and SortedSets
    5:22 Defining the encounter order for List, Set, and SortedSet
    8:10 Properties of LinkedHashSet
    9:09 Common behavior between List, SortedSet and LinkedHashSet
    9:58 Defining the behavior of sequenced collections
    12:10 Adding SequencedCollection and SequencedSet to the Collections API
    13:27 Making Deque implement SequencedCollection
    15:41 Iterating over the elements of a Map
    17:18 Iterating over the elements of a SortedMap or NavigableMap
    18:06 Introducing SequencedMap
    19:06 Creating unmodifiable views with the Collections factory class
    19:16 Outro
    ⎯⎯⎯⎯⎯⎯ Resources ⎯⎯⎯⎯⎯⎯
    ◦ JEP 431: Sequenced Collections ➱ openjdk.org/jeps/431
    ◦ Inside Java Newscast #50 on JDK 21: • All That is in Java 21...
    ◦ Inside Java Newscast #45 on Sequenced Collections: • Java 21's New (Sequenc...
    ◦ Dev.java ➱ dev.java
    ◦ Inside.java ➱ inside.java
    ◦ JDK 21 ➱ openjdk.org/projects/jdk/21
    ◦ OpenJDK ➱ openjdk.org
    ◦ Oracle Java ➱ www.oracle.com/java/
    Tags: #Java #Java21 #OpenJDK #JDK #JDK21 #Collection #JEPCafe #insidejava
  • Наука та технологія

КОМЕНТАРІ • 65

  • @rashimpathak8117
    @rashimpathak8117 22 дні тому

    wondefully explianed.. always wait for your new videos... thx a lot and our best wishes to you

  • @ahmadfx8962
    @ahmadfx8962 11 місяців тому +5

    🙂 great, thank you

  • @faheemsyed9481
    @faheemsyed9481 9 місяців тому +1

    you are fabulous teacher

  • @klarissaclairiton9010
    @klarissaclairiton9010 11 місяців тому +2

    Merci. Tout a été bien expliqué en anglais.

  • @chrisschaefer3863
    @chrisschaefer3863 11 місяців тому +1

    quite sly to manage to finish your coffee at the end of the talk, I was following that from about 1/2 way through thinking it might be the case. well done.

  • @olivierboisse1678
    @olivierboisse1678 10 місяців тому

    Why doesn't Queue extend SequencedCollection interface ?

  • @christianschafer3724
    @christianschafer3724 11 місяців тому +8

    Sequenced Collections starting at 9:10.
    Overall I'd like to see more diagrams and code. Too much information just over audio. This is not a podcast, is it?

    • @mirageman2
      @mirageman2 11 місяців тому +1

      i agree, and without the background music.

    • @srki22
      @srki22 5 місяців тому

      @@mirageman2 I like the background music. There are other videos on this channel about SequencedCollections with more code, but this is intentionally made in this format and I like it.

  • @pablon3115
    @pablon3115 7 місяців тому

    Maybe I'm not getting it well. Because I don't agree when in 8:30 Jose says "Does it have all the properties of List? Not quite. Can you get the third element for instance, that is an element from an index? The answer is yes. Could you remove and element at a given index? The answer is still yes"
    I mean, with a LinkedHashSet you cannot get an element given its index.

    • @roge0
      @roge0 6 місяців тому

      Given he mentions this right after explaining encounter order, I think he was using "index" to refer to an element's place (or *index*) in the encounter order. You're correct that the API for a LinkedHashSet does not provide methods to directly access an element using an index; but, it is still possible to get and remove elements based on their index in the encounter order by using LinkedHashSet#iterator().
      This would be an O(n) operation, but so is LinkedList#get() and LinkedList#remove().

  • @kubarurak
    @kubarurak 11 місяців тому +6

    6:18 why shouldnt you use linkedlists?

    • @KhanhVuy
      @KhanhVuy 11 місяців тому +4

      I have the some question.

    • @FamiliaGrigoryevy
      @FamiliaGrigoryevy 11 місяців тому +1

      probably b/c of the performance reasons

    • @kubarurak
      @kubarurak 11 місяців тому

      @@FamiliaGrigoryevy well duh, but what changed

    • @JonHaa87
      @JonHaa87 11 місяців тому +5

      It can in pretty much all cases be replaced by either ArrayList or ArrayDeque, which both are much faster and consume less memory. Even in cases where LinkedList sounds great, like when using ListIterators to add or remove stuff in the middle of big lists, other data structures are much better.

    • @JosePaumard
      @JosePaumard 11 місяців тому +9

      In a nutshell: because of pointer chasing that kills linked lists performances.

  • @priyeshgupta164
    @priyeshgupta164 10 місяців тому

    🆒

  • @AhmetMurati
    @AhmetMurati 11 місяців тому

    I have not being using LinkedList since years on. I have found also a bug in Java 8 about currency format for Kosova and it is fixed in Oracle Java 8 and newer versions and also at OpenJDK 8 and newer versions.

    • @TheDrezir
      @TheDrezir 11 місяців тому

      I do not fully understand about why LinkedList is bad. I have seen some benchmarks versus ArrayList and AL mostly wins. Probably the resizing of an array in ArrayList is not so demanding nowadays as creation of new objects in LinkedLists with higher memory usage.

    • @jfkwasnoscope
      @jfkwasnoscope 11 місяців тому

      @@TheDrezir Pointer chasing and memory consumption are the big factors.

    • @StefanReich
      @StefanReich 8 місяців тому

      LinkedList has poor cache behavior which can often tank performance@@TheDrezir

    • @alexandersagen3753
      @alexandersagen3753 8 місяців тому

      ​@@TheDrezirModern cpu's are super optimized for working in the same region of memory. So when you fetch some address of ram the cpu also fetches and cached nearby memory. For arraylist this memory is always nearby while for linked list its mostly random where it is. Most operations in arraylists are O(1) time and most of all operations in linked list is O(N) time because iy has to traverse the collection in random memory.

  • @akirsch76
    @akirsch76 11 місяців тому +8

    Why should LinkedList not be used anymore? It is the fastest data structure for random inserts because the following objects do not have to be moved after insertion. For the price that random access is slow.

    • @JosePaumard
      @JosePaumard 11 місяців тому +6

      Hmm... quite not. Pointer chasing is killing all the good properties of linked lists.

    • @manilladrift
      @manilladrift 11 місяців тому +2

      ​​​@@JosePaumardm sorry, what do you mean with that statement?

    • @loganrussell48
      @loganrussell48 11 місяців тому +5

      I'm sure that caching plays a role here in some capacity, since in an array, the memory is all in a contiguous chunk, whereas, with a linked list, the objects are potentially scattered in memory, meaning more cache misses, which would hinder performance? This is purely speculation on my part.

    • @Misa7531
      @Misa7531 11 місяців тому +1

      This part also got my attention, would be good if author could elaborate a little more on this topic.

    • @ahadporkar7355
      @ahadporkar7355 11 місяців тому +1

      Maybe due to cpu caching functionality arraylist almost always outperforms a linked list ?

  • @jopadjr
    @jopadjr 11 місяців тому

    228th...Thanks

  • @JohnLyon0611
    @JohnLyon0611 Місяць тому

    I want to this cup

  • @barcomasile
    @barcomasile 8 місяців тому +1

    I think he's drinking Pepsi

  • @DF-ss5ep
    @DF-ss5ep Місяць тому

    Coffee is for closers. Go back to your cubicle and finish reviewing the PR.

  • @IIIxwaveIII
    @IIIxwaveIII 11 місяців тому +11

    is it possible that this JEP makes the collections framework more confusing and cumbersome then it is?

    • @manilladrift
      @manilladrift 11 місяців тому +9

      Nope

    • @SranSrepfler
      @SranSrepfler 11 місяців тому +9

      No.

    • @StefanReich
      @StefanReich 8 місяців тому +2

      It's a bunch of new, obvious methods and 3 new interfaces. So... no.

  • @softdev8229
    @softdev8229 11 місяців тому

    It will be good if s.o.p changes to print and no "new" keyword

    • @manilladrift
      @manilladrift 11 місяців тому

      Wdym no new keyword

    • @vilpe1989
      @vilpe1989 11 місяців тому

      Well I think like in Kotlin when creating an instance. new Something(); vs. Something();

    • @softdev8229
      @softdev8229 11 місяців тому

      Yes like kotlin and dart

    • @lieven7709
      @lieven7709 11 місяців тому +3

      Wow you win a whole token, imagine the productivity improvements, totally worth it!

    • @manilladrift
      @manilladrift 11 місяців тому

      @@lieven7709 yea I just don't see 'new' as much of a nuisance.. if anything it makes things slightly more explicit

  • @superdupe8
    @superdupe8 4 місяці тому

    quite the cynical and grumpy crowd in the comments section

  • @szaboaz
    @szaboaz 11 місяців тому +4

    "Feeling like taking a coffee break? So do I." English is not my first language, but shouldn't that be "So am I."? Grammar "not see" off.

    • @dr.strangelav4579
      @dr.strangelav4579 11 місяців тому +2

      yup. that's incorrect.

    • @peterg76yt
      @peterg76yt 11 місяців тому +5

      @@dr.strangelav4579 It is incorrect.
      "Feel like a coffee break?" - implied "Do you..." with anticipated 'yes' - appropriate response "So do I".
      "Feeling like a coffee break?" - implied "Are you..." with anticipated 'yes' - appropriate response "So am I".

    • @JosePaumard
      @JosePaumard 11 місяців тому +6

      English is not my first language neither...

    • @JosePaumard
      @JosePaumard 11 місяців тому

      @@peterg76yt Thank you for your comment! I'll fix it in the future episodes.

    • @basilbourque1326
      @basilbourque1326 9 місяців тому +4

      Don't bother changing a thing. Slightly imperfect English is charming, especially when delivered with a French accent. And anyone nitpicking trivial grammar issues from a foreign speaker needs to rethink their priorities - specially when that speaker is generously providing such high-quality technical information. So as we say in imperfect American English: “Keep on keepin’ on". @@JosePaumard

  • @janvandermeer6159
    @janvandermeer6159 6 місяців тому

    Super annoying piano.

  • @sanaullahsianch9962
    @sanaullahsianch9962 11 місяців тому

    if someone starts learning from latest release of java until he finishes learning java there will be at least two new releases of java then he continue to learn relevant technologies used in web like spring framework or again learn latest releases, its better to give up on java and learn python or some other languages

    • @tintifax8531
      @tintifax8531 11 місяців тому +10

      You're saying that other languages don't get new releases, or what is your point? Java is probably the most strictly backward compatible mainstream language out there - just because new versions are released doesn't mean you have to relearn everything.

    • @davidgrajalesmirage
      @davidgrajalesmirage 4 місяці тому +1

      Python breaks far more backward stuff than Java with each release...