
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- 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
- Calling class method through NULL class pointer in C++
- How to capture null reference exception in C#?
- Double Pointer (Pointer to Pointer) in C
- Calling a member function on a NULL object pointer in C++
- Chained exception in Java
- Exception propagation in Java
- Exception chaining in Java
Advertisements