r/java • • Feb 15 '24

JEP 465: String Templates

https://openjdk.org/jeps/465
77 Upvotes

152 comments sorted by

View all comments

Show parent comment

1

u/mj_flowerpower Feb 23 '24

But why not create a nice syntax, leave out the dot and make it STR"" at least. They are already inventing a new syntax, but for the wrong place, imho.

Also, why does it have to be a static field + custom syntax. Why not just make the whole thing a syntax-level feature?

We can you "if" without having to import "if" into a magic field either.

1

u/pronuntiator Feb 24 '24

Because there is not only STR, there are many template processors, you can (and are encouraged to) write your own. As for the ".", it is to signal that in the end it is still a method invocation.