NullPointerException – Eg 1 When Instance of an Object Is set to Null and It Is Used as A reference
java.lang.NullPointerException exception is one of the most popular errors in Java and it is caused by so many issues. One of such issues is when an objected is initiated to a Null value and then its reference is used to call a method or a variable. Example is in the code below. /* * To…