Floating-Point in Java: Representation, Comparison, Equality & A Few Shockers

Floating-point in Java, as in any other modern day programming language, is a complex subject. The versatility, power and the complexity of floating-point numbers is cloaked in innocent looking, simple digits. To harness the real power of floating-point numbers and to use them correctly in Java, it is essential to understand how they are represented… Continue reading Floating-Point in Java: Representation, Comparison, Equality & A Few Shockers

Java Ternary Operator a.k.a Conditional Operator

The conditional operator is very similar to the if/else or switch conditional statements and is the only operator in Java that takes three operands. Therefore, conditional operator is also known as ternary operator. This operator not only has three operands but can also be used in variety of ways to make the code more concise. So, we take a deeper than… Continue reading Java Ternary Operator a.k.a Conditional Operator

Java EnumMap with Example

Java EnumMap is a Java Map that uses keys of a single enum type. EnumMap utilizes the inherent associative nature of arrays and is therefore the most efficient implementation of Map.  In a nutshell, EnumMap is a one-trick-pony designed to be used when the keys of your Map are constants and therefore can be made static and final. Constructors of EnumMap… Continue reading Java EnumMap with Example