What is NullPointerException in Java how to deal

Tutorials Shared by the Internet Community

Advertisements


Synopsis

Java.lang.NullPointerException comes when we try to access any field or method on Object which is null. Its come mainly due to programming mistake and

Statistics

  • Total Hits - 26883

  • Total Votes - 100 votes

  • Vote Up - 43 votes

  • Vote Down - 57 votes

  • Domain - javarevisited.blogspot.sg

  • Category - JAVA/Core JAVA

  • Submitted By - Javin Paul

  • Submitted on - 2012-09-22 08:32:16

Description

Java.lang.NullPointerException comes when we try to access any field or method on Object which is null. Its come mainly due to programming mistake and breaking of contract between different part of application but there are few cases where you can avoid NullPointerException in Java by carefully coding like instead of object.equals("apple) you can call "apple".equals(object) which will not throw NullPointerException. ...


Site  |   Broken  |   Tweet  |   Facebook  |     |   Save  |   Liked  |   Down

Advertisements