February 2017

Wrapper Classes in Java

  • Satish 

1. Overview As the name suggests, wrapper classes are objects encapsulating primitive Java types. Each Java primitive has a corresponding wrapper: boolean, byte, short, char, int, long, float, double  Boolean, Byte, Short, Character, Integer, Long, Float, Double These are all defined in the java.lang package, hence we don’t need to import them manually. 2. Wrapper Classes “What’s the purpose of a wrapper class?”. It’s one of the most common Java interview questions. Basically, generic classes only work with objects and don’t support primitives. As a result, if… Read More »Wrapper Classes in Java

Using Java Assertions

  • Satish 

1. Introduction The Java assert keyword allows developers to quickly verify certain assumptions or state of a program. In this article, we’ll take a look at how to use the Java assert keyword. 2. History of Java Assertions The Java assert keyword was introduced in Java 1.4, so it’s been around for quite a while. However, it remains a little-known keyword that can drastically reduce boilerplate and make our code more readable. For example, often times in our code we need to verify certain conditions that might… Read More »Using Java Assertions