Understanding Java Class Loaders

Introduction We will see here what are the Java class loaders with simple example. Java publicly released in the year of 1995 with a web browser with the ability to automatically and dynamically download applets whenever it encounters <Applet> tag in the HTML document. Such Applets are loaded on the fly across the network from remote web servers and run inside the browser’s Java Virtual Machine (JVM). The mechanism that enabled such dynamic loading is a class loader. Class loaders are responsible for determining when and how classes can be…

Continue

Exception vs Error in Java

I will tell you here what are the differences between Exception and Error in Java. There are mainly three important categories of Throwable: Error – something severe enough has gone wrong the most applications should crash rather than try to handle the problem. Unchecked Exception (also known as, RuntimeException) – mainly a programming error, such as, a NullPointerException or an illegal argument. Applications can sometimes handle or recover from this Throwable category or at least catch it at the Thread’s run() method, log the complaint, and continue running. Checked Exception…

Continue

Local Class in Java

Local class or classes in Java are defined in a block, which is a group of zero or more statements between balanced braces. We typically find local classes defined in the body of a method. We can define a local class in Java inside any block. In this example we will create a local class to validate email address using regex pattern or regular expression.

Continue

Wrapper Class in Java

I will tell you here what is wrapper class in Java. The primitive data types are not objects; so they do not belong to any class; they are defined in the language itself. Sometimes, it is required to convert data type into an object in Java language. For example, up to JDK 1.4, the data structure accepts only objects to store.

Continue