We moved our projects from #Java 11 to #Java 17 almost right after the LTS release. Here is a list of the Top 5 features that I have used and enjoyed for more than a year that may convince you to upgrade your projects. ๐งต๐
`
record Point(int x, int y) {}
`
- this all you need to create POJO. No, constructors, getters, setters, etc. Just removed verbosity, which was disliked and criticized by many community members. ๐
Text blocks:
`String text = """
Long
formated
text.
""";
`
My SQL queries and JSON blocks in tests don't look like graveyards with all those `+.` โโ
Switch exceptions:
`
boolean isWeekend = switch (day) {
case SATURDAY, SUNDAY -> true;
default -> throw IllegalStateException("I's not weekend.");
};
`
More readable and less error-prone, and you won't forget to write a `break` at the end of the block. ๐ผ
Pattern Matching for instanceof:
`if (x instanceOf String s) {
int length = s.length();
}
`
No more (casting) inside the block. The code is less messy.๐ฏ
Helpful NullPointerExceptions:
` person.wife.name = "Lidia";
`
throws:
Cannot assign field "name" because "person.wife" is null
java.lang.NPE: Cannot assign field "name" because "person.wife" is null
Finally, NPE describes exactly which variable was null.๐ฅณ
Sealed classes:
`
public abstract sealed class Event
permits Start, Launch, Stop {}
`
If you ever wanted more power over who is allowed to extend your classes.๐
That's it. Thanks for reading.
If you are convinced to migrate to #Java 17 now, then like, retweet, and follow me for more content like this.
Happy Upgrade!๐
โข โข โข
Missing some Tweet in this thread? You can try to
force a refresh
AssertJ by @JoCosti - fluent chaining assertions java library. One of the most powerful and convenient ways to write assertions. It's also included in the @springboot test framework.
Often Software Developers are also called Professional Googlers. This means that we need to be really proficient in it. So this thread will provide you with tips and tricks which help you to become #10xengineer in Googling. Let's start โก๏ธโก๏ธโก๏ธ
1. Use quotes for "exact match" searches. Often when you search for a particular error message try searching with quotes first to get your results faster. Very helpful when you need to understand error or warning messages in logs.
2. Use '*' in as a wildcard. Use case: when searching for errors messages replace parts specific to your code(folder or package names). Also helpful you want to find a song, but remember only some words then replace the unknown part with '*'. ๐ถ