Java 17 to 20 Pattern Matching Full tutorial with Records, Instanceof and Switch - JEP Café #14

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024

ความคิดเห็น • 55

  • @Jamie35719
    @Jamie35719 10 หลายเดือนก่อน +1

    Feel like I could watch this gentleman talk about Java all day long. This is my third video. Love the content and delivery!

    • @java
      @java  10 หลายเดือนก่อน +1

      Glad you enjoyed it!

  • @mikaelogren
    @mikaelogren ปีที่แล้ว +20

    Really appreciate these videos and the format of them! Thanks!

    • @java
      @java  ปีที่แล้ว +2

      Glad you like them!

  • @ppdmartell
    @ppdmartell ปีที่แล้ว +3

    I like these kind of videos. Seems to me like finding hidden pearls to be used.

  • @arthurezeagbo3986
    @arthurezeagbo3986 ปีที่แล้ว +4

    It gives me joy listening and learning from you. Thank you sir!

    • @java
      @java  ปีที่แล้ว

      So nice of you

  • @larryd9577
    @larryd9577 ปีที่แล้ว +8

    I'm really looking forward to Java 21

    • @gabrielfreitas4270
      @gabrielfreitas4270 ปีที่แล้ว

      Man your pfp are the dudes from my work "Wait, is there any Java version after 8?"

    • @larryd9577
      @larryd9577 ปีที่แล้ว

      @@gabrielfreitas4270 I am running with this pfp for a decade now. And I've seen fireships video as well.

  • @dvyadav2307
    @dvyadav2307 7 หลายเดือนก่อน

    Nice and clear explanations.
    All I need now is a java cup ☕

  • @mlouiedc
    @mlouiedc ปีที่แล้ว

    Nicely delivered, clear and simple.

  • @dennisvanmierlo
    @dennisvanmierlo ปีที่แล้ว

    Hi Jose, A great video! You are a great teacher. I love your courses on Pluralsight. Thank you and enjoy your Java coffee ☕
    Lot’s of greetings, Dennis 🇳🇱

  • @AkhileshKumar-cs2kh
    @AkhileshKumar-cs2kh ปีที่แล้ว +4

    Thanks for the awesome video

  • @captainjava1
    @captainjava1 ปีที่แล้ว +2

    Around 11:00, I think switch(Shape shape) should be just switch(shape), with the variable previously declared... I'm enjoying the video enough to be trying examples with the Early Access release and old-school command-line javac and java commands!

    • @Muescha
      @Muescha ปีที่แล้ว

      that was also a question i see at this point - whats the right feature?

  • @vortexmodeling
    @vortexmodeling ปีที่แล้ว +3

    Cool, do you know what also is cool? The Java coffee cup you got! Would love to have one on my desk and flex on my colleagues : )

  • @svalyavasvalyava9867
    @svalyavasvalyava9867 ปีที่แล้ว

    Thank you so much for this video!

  • @rolandinnamorato1953
    @rolandinnamorato1953 ปีที่แล้ว +1

    Super Java evolution

  • @zohahs5276
    @zohahs5276 ปีที่แล้ว +1

    Nice do you have a full course on Java core programming from A to Z thanks.

  • @aloussase
    @aloussase ปีที่แล้ว

    Nice! Next steps: pattern matching in function and lambda arguments

  • @redcrafterlppa303
    @redcrafterlppa303 ปีที่แล้ว +11

    It would be great if record patterns could be used on assignments like this:
    Point(int x, int y) = foo.getPoint();

    • @JosePaumard
      @JosePaumard ปีที่แล้ว +6

      That's part of the future plans. Maybe it will come?

  • @redcrafterlppa303
    @redcrafterlppa303 ปีที่แล้ว +2

    9:00 this is great. But the syntax is unnatural. I wonder if there is a syntactic better way to expose s to the rest of the method that is more clear.

  • @RakeshKumar-tu6bi
    @RakeshKumar-tu6bi ปีที่แล้ว

    In for(Points(double x, double y) : pts) instead of having to mention double data type every time it is better to provide a generic type so as to avoid exception while iterating. *Generic types can be bounded*
    One more thing is that there could be a third point for z-axis(double z) so there must be an overloaded constructor. So it is much better to have a vararg parameter. I don't how this will affect performance and memory. I haven't read the docs properly so it's just an idea from this video.

    • @tanveerhasan2382
      @tanveerhasan2382 ปีที่แล้ว

      You can use _for(Points(var x, var y) : pts)_ instead of mentioning double twice

  • @JorgetePanete
    @JorgetePanete ปีที่แล้ว

    Would it be a good idea to be able to have more than one variadic parameter, such that one takes the odd elements and the other takes the even elements? Useful for Map.of

  • @jorgerangel2390
    @jorgerangel2390 ปีที่แล้ว

    Is it too difficult for the language to infer the type of o based on the assertion in the if statement so inside the if o is an string without the need of a new variable?

  • @amirhosseindolatkhah2924
    @amirhosseindolatkhah2924 ปีที่แล้ว

    Adding features to java is making me an old man, how slowly it is going on.

  • @hellowill
    @hellowill ปีที่แล้ว

    Will there be boolean only patterns when you've got a single type?
    E.g.
    List is Empty -> ...
    default -> ...

    • @fertiz_
      @fertiz_ ปีที่แล้ว

      just check with `if` condition, I think there is no need for that in switch

    • @RichardKures
      @RichardKures ปีที่แล้ว +3

      @@fertiz_ You can use: case List l when l.isEmpty() -> { } instead of the if.

  • @whitewoodcity9612
    @whitewoodcity9612 ปีที่แล้ว

    Why not release switch pattern directly?
    AFAIK, preview feature should be completed in 12 months

    • @JorgetePanete
      @JorgetePanete ปีที่แล้ว

      It's in preview to receive feedback, and the development time depends entirely on the feature...

    • @JosePaumard
      @JosePaumard ปีที่แล้ว +1

      Sometimes but not always. Some may even be removed without becoming final features. It happened with Raw String. It all depends on the feedback.

  • @cya3mdirl158
    @cya3mdirl158 3 หลายเดือนก่อน

    Fortunately we have Kotlin. In Kotlin code is more expressive.

  • @stIncMale
    @stIncMale ปีที่แล้ว +2

    17:55 - `for` loop throwing exception if an `Iterable` is empty when pattern matching is used is just terrible, insane even, and is absolutely counter intuitive.

    • @alessioantinoro5713
      @alessioantinoro5713 ปีที่แล้ว +4

      Not when it is empty, when it contains null values

    • @JosePaumard
      @JosePaumard ปีที่แล้ว +1

      I'm not so sure that putting null values in a collection is a such great idea 😄

    • @stIncMale
      @stIncMale ปีที่แล้ว +1

      ​@@alessioantinoro5713 Oh, thanks! I re-watched, and I still hear "especially if you have NO elements in this list" if I don't make effort to really listen and hear "NULL elements", now that I know what the phrase actually is. Of course, with `null` elements that behavior totally makes sense.

    • @stIncMale
      @stIncMale ปีที่แล้ว +2

      @@JosePaumard I misheard the phrase and confused "NULL elements" with "NO elements".

    • @alessioantinoro5713
      @alessioantinoro5713 ปีที่แล้ว

      @@stIncMale No wonders! It happens

  • @vat78nnov
    @vat78nnov ปีที่แล้ว

    Pattern matching is required for functional programming. But this is anti-pattern in OOP (example with Shape is not in OOP style)
    And on practice people will use it for creating ugly procedural code

    • @BangsarRia
      @BangsarRia 2 หลายเดือนก่อน

      This is niche. In a case where you are already using runtime polymorphism and you want to add an ancilliary feature that would violate other principles, switch with lambda can provide an easier and more readable solution. Nicholai Parlog has a TH-cam where he codes suitable examples.

  • @IfeSunmola
    @IfeSunmola 10 หลายเดือนก่อน

    8:39 is really weird. Everyone that has used curly brace languages knows variables only exist in the { } they're declared in.
    Sure, it's not hard to wrap your head around it, but maybe it could have been done in another way ...

  • @betancour
    @betancour ปีที่แล้ว

    Java is looking very LISP with those Parentheses...

  • @AkhileshKumar-cs2kh
    @AkhileshKumar-cs2kh ปีที่แล้ว

    Happy to see that java is copying useful features from other languages, but worried it will ruin existing ones