- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Null Pointer Exception in Java Programming
NullPointerException is a runtime exception and it is thrown when the application try to use an object reference which has a null value.
For example, using a method on a null reference.
Example
public class Tester { public static void main(String[] args) { Object ref = null; ref.toString(); // this will throw a NullPointerException } }
Output
Exception in thread "main" java.lang.NullPointerException at Tester.main(Tester.java:4)
- Related Articles
- Null Pointer Exception in C#
- What is null pointer exception in Java and how to fix it?
- Exception propagation in Java programming
- NULL pointer in C
- Differentiate the NULL pointer with Void pointer in C language
- Explain the concept of Array of Pointer and Pointer to Pointer in C programming
- Explain reference and pointer in C programming?
- Null Aware Operators in Dart Programming
- How to capture null reference exception in C#?
- Calling class method through NULL class pointer in C++
- Calling a member function on a NULL object pointer in C++
- Exception propagation in Java
- Exception chaining in Java
- Why is address zero used for the null pointer in C/C++?
- Chained exception in Java\n

Advertisements