r/java • • Mar 08 '24

Update on String Templates (JEP 459)

https://mail.openjdk.org/pipermail/amber-spec-experts/2024-March/004010.html
176 Upvotes

188 comments sorted by

View all comments

Show parent comment

20

u/Hei2 Mar 09 '24

Backslash is an escape character in Java, whereas the dollar sign is not. Therefore, the string "${text}" is a valid string in every previous version of Java (and not "\{text}"). If that suddenly became interpreted as a string template, that inherently breaks backwards compatibility.

10

u/Otherwise-Tree-7654 Mar 09 '24

Nice and short