No Image

How to use typesafe enums in Java

Java code that uses traditional enumerated types is problematic. Java 5 gave us a better alternative in the form of typesafe enums. In this article, I introduce you to enumerated types and typesafe enums, show you how to declare a typesafe enum and …

No Image

How to use assertions in Java

Writing programs that work correctly at runtime can be challenging. This is because our assumptions about how our code will behave when executed are often wrong. Using Java’s assertions feature is one way to verify that your programming logic is sou…