ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

When java doesn't support pointers why does it throws null pointer exception?

user-image
تم إضافة السؤال من قبل Venkata Lakshmi
تاريخ النشر: 2016/02/24
Tarun Kumar
من قبل Tarun Kumar

A reference variable of class which has null reference and is used to access the any object of class, then it will throw null pointer exception.

Sivasri Dola
من قبل Sivasri Dola

Object references are nothing but pointers but they are not complex as Pointers.

Lathesh Karkera
من قبل Lathesh Karkera , Java Developer/It Developer , Unikaihatsu Software Pvt Ltd

Pointers are used in Java implementation for references (Oracle JDK is implemented in C++) who develop/implement the language. It is just that pointers are not accessible to developers who use it.

Azizuddin Khan
من قبل Azizuddin Khan , JAVA-Developer

Definitely there are pointers in Java and the null pointer error is one of them but they are managed by the JVM. However, you are not required to deal with them "directly" as you do with C++. You create references by delclaring new variables.. They are pointers. When you declare a variable "pointer" then you need to initialize before using this variable.. otheriwse you will get an error.

Rana Pratap
من قبل Rana Pratap , BDS services

At JVM level everything is pointer. but at java programmer only sees this using references.In actual case the pointer in c/c++ is not related to this exception "NullPointException".This is thrown when we try to call null value or references.

Umesh Botke
من قبل Umesh Botke

Actually, This pointer is not related to c or c++ pointer.In NullPointerException, pointer has dictionary meaning. And when we call any method on null reference then we will get 'NullPointerException' exception.

zakaul haque
من قبل zakaul haque , Associate Analyst , Global Logic Pvt Ltd

Java Objects need references to its handle which points to it in the stack area When these are not referenced it throw NULL pointer Exception.

To point this out to converted C/C++ programmers, they did not carry the C name over, but named it something else. At the JVM level everything is pointers, but as Java programmers only see this when using references, the exception is badly named.

 Java does indeed have pointers. They can have two kinds of values: (a) references to objects, or (b) null. This is the language used in the Specification.

vishal patil patil
من قبل vishal patil patil , Software Devoloper , KCLINK TECHNOLOGIES

To point this out to converted C/C++ programmers, they did not carry the C name over, but named it something else. At the JVM level everything is pointers, but as Java programmers only see this when using references, the exception is badly named.

shahensha burhan mogulluru
من قبل shahensha burhan mogulluru , JAVA DEVELOPÉR , ICUBE IT SERVICES PVT LTD

We don't use pointers in java. But internal implementation of JVM uses pointers.  When you allocate memory for an object by calling new, you get back a pointer.

Kamran Ali Siddiqui
من قبل Kamran Ali Siddiqui , Programmer , Infocomm Group LLC

Java internally handle pointers but java does not let programmer handle pointers that is the reason Java throws null pointer exception.

Thanks

المزيد من الأسئلة المماثلة