• AkisambOP
    link
    fedilink
    English
    arrow-up
    8
    ·
    2 years ago

    I imagine that everybody in this community has seen this JEP, but I’m just so happy that we finally have exhaustive pattern matching in java.

    My job has also announced a multi-million plan to get rid of websphere and java 8, so maybe I may even see these features at my job one day ^^

    • lowleveldata
      link
      fedilink
      English
      arrow-up
      6
      ·
      2 years ago

      to get rid of websphere and java 8

      haha, I was going to say “cool feature but I’m still on Java 8 / 11”

      • JackbyDevM
        link
        fedilink
        English
        arrow-up
        3
        ·
        2 years ago

        In 2014 my first job as a junior developer we were on Java 6 on WebSphere. We didn’t even get try-with-resources lol.

        • MagicShel
          link
          fedilink
          English
          arrow-up
          2
          ·
          2 years ago

          I think in 2014 I was working on Java 5. Then maybe 5 years later we went to 7. Then I changed jobs to a place on 6. Then we migrated to 8.

          Since then I think I’ve had one project on Java 11 and everything else has been Java 8.

          I do have a persona side project on Java 20, at least.

    • JackbyDevM
      link
      fedilink
      English
      arrow-up
      4
      ·
      2 years ago

      Friend, I pray that you are going to at least Java 17 and not to 11 lol. Heck, if you can wait a few months 21 will be out and you’ll have virtual threads! (Actually I can’t remember if it is a preview in 21 or not off the top of my head.)

      • AkisambOP
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 years ago

        The target is 17 at the moment, but I’m keeping hope for version 21.

  • JackbyDevM
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 years ago

    Example code from the link for the lazy,

    // As of Java 21
    static String formatterPatternSwitch(Object obj) {
        return switch (obj) {
            case Integer i -> String.format("int %d", i);
            case Long l    -> String.format("long %d", l);
            case Double d  -> String.format("double %f", d);
            case String s  -> String.format("String %s", s);
            default        -> obj.toString();
        };
    }