Which is the best approach: singletons, sealed classes, abstract classes, final classes, or enums?Imagine that your design requires exactly four instances of a particular class.Which approach best provides for this need? Choose one.A. Singletons B. Sealed classes C. Abstract classes D. Final classes E. Enums Answer. Option A is incorrect...
Friday, August 26, 2022
Wednesday, August 24, 2022
The arrival of Java 17!
Oracle is proud to announce the general availabilty of JDK 17. This release is the eighth Feature Release delivered on time through the six-month release cadence. This level of predictability allows developers to easily manage their adoption of innovation thanks to s steady stream of expected changes.Java’s ability...
Monday, August 22, 2022
Quiz yourself: Creating records within a Java sealed-type hierarchy
A record type is always implicitly final, so it cannot be extended by either a regular class or a record.You’re designing an IoT device controlled by Java. The device has two modes, one for day and one for night. The modes differ in terms of configuration data, and...
Friday, August 19, 2022
Declarative and Immutable Pipeline of Transformations
A few months ago I made a small Java library, which is worth explaining since the design of its classes and interfaces is pretty unusual. It’s very much object-oriented for a pretty imperative task: building a pipeline of document transformations. The goal was to do this in a...
Monday, August 8, 2022
Developers disassemble! Use Java and hsdis to see it all.
Use the HotSpot Disassembler to see what’s happening to your code.Figure 1 below is what you might see when you ask your Java Virtual Machine (JVM) to show you the output of a just-in-time (JIT) compilation performed by the HotSpot JVM after it optimized your program to take...