![]() Your email address will not be published. You might also agree that NullPointerException is pain for most of java developers(novice or expert), but there is not much we can do about them, because this is the price we need to pay for convenient or unavoidable null references. I am sure that this is the exception you might have encountered most frequently. Raise your hand if you ever got NullPointerException while working on java code. In this tutorial, we will see the most frequent java exception i.e. Best practices for avoiding NullPointerException.Do null check as well before putting key or value in Collection which do not allow null When you add null to Collections which do not allow nulls such as ConcurrentHashMap Throwing null as if it were a Throwable value. Accessing or modifying the slots of null as if it were an array. ![]() Taking the length of null as if it were an array. Accessing or modifying the field of a null object. Invoking the instance method of a null object
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |