Java final abstract class

You can’t get much simpler than using an enum with no instances. public enum MyLib {; public static void myHelperMethod() { } } This class is final, with explicitly no instances and a private constructor. This is detected by the compiler rather than as a runtime error. (unlike throwing an exception)

Java – Can final variables be initialized in static initialization block?

Yes of course: static final variables can be initialized in a static block but…. you have implicit GOTOs in that example (try/catch is essentially a ‘GOTO catch if something bad happens’). If an exception is thrown your final variables will not be initialized. Note that the use of static constructs goes against Object-Oriented dogma. It … Read more