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

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

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

  • @Jamie35719
    @Jamie35719 Год назад +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  Год назад +1

      Glad you enjoyed it!

  • @mikaelogren
    @mikaelogren 2 года назад +20

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

    • @java
      @java  2 года назад +2

      Glad you like them!

  • @ppdmartell
    @ppdmartell 2 года назад +3

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

  • @arthurezeagbo3986
    @arthurezeagbo3986 2 года назад +4

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

    • @java
      @java  2 года назад

      So nice of you

  • @dvyadav2307
    @dvyadav2307 10 месяцев назад

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

  • @dennisvanmierlo
    @dennisvanmierlo 2 года назад

    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 🇳🇱

  • @mlouiedc
    @mlouiedc 2 года назад

    Nicely delivered, clear and simple.

  • @captainjava1
    @captainjava1 2 года назад +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 2 года назад

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

  • @larryd9577
    @larryd9577 2 года назад +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.

  • @AkhileshKumar-cs2kh
    @AkhileshKumar-cs2kh 2 года назад +4

    Thanks for the awesome video

  • @rolandinnamorato1953
    @rolandinnamorato1953 2 года назад +1

    Super Java evolution

  • @vortexmodeling
    @vortexmodeling 2 года назад +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 2 года назад

    Thank you so much for this video!

  • @aloussase
    @aloussase 2 года назад

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

  • @redcrafterlppa303
    @redcrafterlppa303 2 года назад +11

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

    • @JosePaumard
      @JosePaumard 2 года назад +6

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

  • @zohahs5276
    @zohahs5276 2 года назад +1

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

  • @jorgerangel2390
    @jorgerangel2390 2 года назад

    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 2 года назад

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

  • @redcrafterlppa303
    @redcrafterlppa303 2 года назад +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.

  • @JorgetePanete
    @JorgetePanete 2 года назад

    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

  • @RakeshKumar-tu6bi
    @RakeshKumar-tu6bi 2 года назад

    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 2 года назад

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

  • @hellowill
    @hellowill 2 года назад

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

    • @fertiz_
      @fertiz_ 2 года назад

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

    • @RichardKures
      @RichardKures 2 года назад +3

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

  • @stIncMale
    @stIncMale 2 года назад +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 2 года назад +4

      Not when it is empty, when it contains null values

    • @JosePaumard
      @JosePaumard 2 года назад +1

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

    • @stIncMale
      @stIncMale 2 года назад +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 года назад +2

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

    • @alessioantinoro5713
      @alessioantinoro5713 2 года назад

      @@stIncMale No wonders! It happens

  • @IfeSunmola
    @IfeSunmola Год назад

    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 ...

  • @whitewoodcity9612
    @whitewoodcity9612 2 года назад

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

    • @JorgetePanete
      @JorgetePanete 2 года назад

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

    • @JosePaumard
      @JosePaumard 2 года назад +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 6 месяцев назад

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

  • @vat78nnov
    @vat78nnov 2 года назад

    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 5 месяцев назад

      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 RUclips where he codes suitable examples.

  • @betancour
    @betancour 2 года назад

    Java is looking very LISP with those Parentheses...

  • @AkhileshKumar-cs2kh
    @AkhileshKumar-cs2kh 2 года назад

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