Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on programming.dev

7 replies

programming.dev

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

7
programming.dev

to get rid of websphere and java 8

haha, I was going to say "cool feature but I'm still on Java 8 / 11"

6
JackbyDevreply
programming.dev

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.

3

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.

2
JackbyDevreply
programming.dev

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

4

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();
    };
}
3

You reached the end

JEP 441: Pattern Matching for switch | Spyke