July 2017

ClassNotFoundException vs NoClassDefFoundError

  • Satish 

1. Introduction Both ClassNotFoundException and NoClassDefFoundError occur when the JVM can not find a requested class on the classpath. Although they look familiar, there are some core differences between these two. In this tutorial, we’ll discuss some of the reasons for their occurrences and their solutions. 2. ClassNotFoundException ClassNotFoundException is a checked exception which occurs when an application tries to load a class through its fully-qualified name and can not find its definition on the classpath. This occurs mainly when trying to load classes using Class.forName(), ClassLoader.loadClass() or ClassLoader.findSystemClass(). Therefore,… Read More »ClassNotFoundException vs NoClassDefFoundError

Guide to UUID in Java

  • Satish 

1. Overview UUID (Universally Unique Identifier), also known as GUID (Globally Unique Identifier) represents a 128-bit long value that is unique for all practical purposes. The standard representation of the UUID uses hex digits (octets): 123e4567-e89b-12d3-a456-556642440000 A UUID is made of up of hex digits  (4 chars each) along with 4 “-” symbols which make its length equal to 36 characters. The Nil UUID is a special form of UUID in which all bits are set to zero. In this article, we will… Read More »Guide to UUID in Java

How to Round a Number to N Decimal Places in Java

  • Satish 

1. Overview In this short article, we’re going to look at how to round a number to n decimal places in Java. 2. Decimal Numbers in Java Java provides two primitive types that can be used for storing decimal numbers: float and double. Double is the type used by default: double PI = 3.1415; However, both types should never be used for precise values, such as currencies. For that, and also for rounding, we can use the BigDecimal class. 3. Formatting a Decimal Number If we just want to print… Read More »How to Round a Number to N Decimal Places in Java