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

Поделиться
HTML-код
  • Опубликовано: 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.

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

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

    Nicely delivered, clear and simple.

  • @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 : )

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

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

  • @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?

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

    Thanks for the awesome video

  • @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?

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

    Thank you so much for this video!

  • @rolandinnamorato1953
    @rolandinnamorato1953 Год назад +1

    Super Java evolution

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

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

  • @zohahs5276
    @zohahs5276 Год назад +1

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

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

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

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

  • @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?

  • @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

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

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

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

  • @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