Pattern Matching in instanceofThe traditional usage of instanceof operator requires typecasting inside the if block, i.e., if (obj instanceof String) { String s = (String) obj; ... } Though the block inside if gets executed only if obj X is a type of String object, the ja...Dec 1, 2021 · 2 min readblog.commitbyte.com
Pattern matching comes to Switches in JavaSwitches in Java lacked an option to match a value based on an expression that is computed at runtime(similar to C). So the values against which a value can be matched should be constant known at compile time. Below is the current format of switch th...Nov 30, 2021 · 3 min readblog.commitbyte.com
Java Sealed TypeJava classes by default are open for extension. A library class created and compiled years ago can be extended by any of the future classes and its implementation can be altered. Though this looks powerful, there are a few instances where one might n...Nov 29, 2021 · 3 min readblog.commitbyte.com
Java RecordsJava language is known for being too much verbose which results in writing an ample number of lines to store immutable data fetched from a database or URL connection for processing. Java records(first introduced in J14 and finalized in J16) provide a...Nov 28, 2021 · 2 min readblog.commitbyte.com
Understanding the need for Thread-Safe variables using a basic counter in JavaParallelization is being done to use the number of cores available in servers and to reduce the time taken for execution. But if race condition isn't handled properly for required variables, it could create unexpected issues in our application. First...Dec 18, 2020 · 6 min readblog.commitbyte.com