Java 21 will be released this week. Let's take a quick look at the key features arriving in this release in two minutes... more or less. More info ➱ inside.java Tags: #Java #OpenJDK #Java21 #JDK21
I like the way this video was done. It is best to start with a short overview, like this video and then go on to progressively more in depth videos depending on viewer interest.
1:43 I wish they would have gone the Kotlin route of string templates. It will definitely take some adjusting to get used to the Java way, when released.
The \{title} is used because it's invalid syntax when used in a String and it would be a way for the compiler to know what is a normal String and what is a String template. Because of the existing base of Java code, making the switch to use ${} would cause Java users A LOT of pain. Far more than it would be conceivably be worth than the relatively low cost of learning that \{} is used in Java instead of ${}.
Hmmm... a bit to unpack here... yield is used for a multi-line case for a switch expression using the -> syntax, or any switch case using : syntax. However it's a common misconception that all switches using -> are expressions, they can also be statements (they don't yield value), in which case you wouldn't use yield. They also don't need to be exhaustive (expression must be exhaustive). However again, if you are using pattern matching, in either a expression or statement (with -> or : syntax), it does need to be exhaustive.