Showa Shafkat

Showa Shafkat

To describe myself i am a I am an organized IT professional with Forte in Java and java based framework. I have close to 6.5 Yrs of exp into IT.

java.lang.UnsupportedOperationException while adding element to List created from Arrays.asList()

The arraylist which is created using below line of code is immutable. The reason behind is the list still backed/aided by the array and we all know pretty well that the size of the array cannot be changed. The Arrays.asList returns the arraylist which is the inner class with the name as arraylist. This list does not have methods that performs any modification to the arraylist add, remove etc. It is an inner class which extends abstract class AbstractList but not…

0
Read More

Try with Resources in Java

Introduction: The try-with-resources statement introduces in Java 7 is a try statement that declares one or more resources.A resource is an object that must be closed after the program is finished with it.The try-with-resources statement ensures that each resource is closed at the end of the statement.Any object that implements java.lang.AutoCloseable interface, which includes all objects which implement java.io.Closeable,can be used as a resource. see the below sample code:- Note: More than two resources can be added separated by a…

0
Read More

Restart a thread Using UncaughtExceptionHandler

There is always a scenario in a development process where a piece of any code/line (e.g.,business logic) throws some unchecked/runtime exception which is not possible to handle as we are not sure about the user input. In that case the thread responsible for executing that piece of code dies off and the assigned task remain unfinished. Due to this the output may not be consistent and the reuslt can be pretty random. Let us take the below example, To overcome…

0
Read More