What is a NullPointerException in Java

In this post we will explain what is a NullPointerException in Java, and how to fix these issues. What is a NullPointerException in Java An application will throw a null pointer exception when you are invoking a method on an object who's value is null. Lets have a look at the example below.

Running … Continue reading What is a NullPointerException in Java

Convert an Object to a Map in Java

In this post we will provide an example on how to convert an object to a map in Java. Setup: You will need to include the following dependency

Convert an Object to a Map in Java: The example below uses a User object which has the following properties Name Age Address (which is another … Continue reading Convert an Object to a Map in Java

Java ExecutorService examples

This post will provide a brief description of the different types of ExecutorService available in java. This post will also include some Java ExecutorService examples. What is the ExecutorService: The executor service is provided by the java JDK because it helps simplifies the execution of asynchronous tasks. It provides a pool of threads and an API allowing you … Continue reading Java ExecutorService examples

Handle an exception thrown by a callable

In this post an example is provided to demonstrate how to handle an exception thrown by a Callable object. Handle exception thrown by callable:

A few points to note from the above code. A callable object which throws a RuntimeException, is passed into the submit() method. The result of the callable object is retrieved … Continue reading Handle an exception thrown by a callable

How to create a Thread in Java

In this post we will provide an example of how to create a thread in Java. A thread can be created by either extending the thread class or implementing the runnable interface. How to create a Thread in Java Example 1: Extending the Thread class.

The above class extends the Thread class and overrides … Continue reading How to create a Thread in Java

How to move a file in Java

In this post we will provide an example of how to move a file in Java. This example uses the standard java libraries so you will not need any external dependencies. How to move a file in Java: The example below uses the Files class which is available from Java 1.7 and above.

  … Continue reading How to move a file in Java