answersLogoWhite

0

A null pointer exception is thrown when you are trying to manipulate an object that is null. It is just the name and does not have any relevance to the pointers as in C

Example:

ArrayList lst = null;

Object obj = lst.get(0);

In the first line we have declared an array list. Without initializing it we have tried to access the element in the 0th position. This would cause a null pointer exception.

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

What is pointer in java?

There is no concept similar to pointers in Java. Pointers are a feature in C programming using which a programmer can access the memory. This was the cause of major catastrophic programming bugs. The creators of Java excluded this feature just to avoid such catastrophic bugs.


Why do java consider pointer as dangerous?

programmers are always confused with pointers


How can you fix uncaught exception java lang Null Pointer Exception on blackberry 8300?

The best way to fix uncaught exception java lang Null Pointer Exception on a Blackberry 8300 is by doing a restart. Shut the phone off and remove the battery for a minute. Replace the battery and turn the phone back on.


In C you use the concept of pointers whereas there are no pointers used in JAVA why?

Pointers in C are generally the thing that gives learners the most trouble. When C code is not written correctly with respect to pointer use, the resulting bugs can often be very difficult to find and correct. On the other hand, pointers are absolutely necessary in some cases.The designers of Java wanted to make programming easier and hence avoided adding pointers to the language. Java does have object references which accomplish much of what pointers accomplish albeit in a safer way.


Do other programming languages implement pointers?

All programming languages implement pointers, but not all languages allow low-level access to memory through a raw pointer. Java, for instance, uses resource handles and smart pointers rather than raw pointers, however the actual allocation of memory is handled by the Java virtual machine (JVM) so there is no need for low-level raw pointers.

Related Questions

What is pointer in java?

There is no concept similar to pointers in Java. Pointers are a feature in C programming using which a programmer can access the memory. This was the cause of major catastrophic programming bugs. The creators of Java excluded this feature just to avoid such catastrophic bugs.


What you use in case of pointer in java?

Java does not have pointers


What are the background pointers in java?

Java does not support pointers.


Can you use pointers in java?

Java does not support Pointers and hence you cannot use it in Java.


Why do java consider pointer as dangerous?

programmers are always confused with pointers


How can you fix uncaught exception java lang Null Pointer Exception on blackberry 8300?

The best way to fix uncaught exception java lang Null Pointer Exception on a Blackberry 8300 is by doing a restart. Shut the phone off and remove the battery for a minute. Replace the battery and turn the phone back on.


Pointers are replaced by what in java?

Nothing. Java does not have a concept that is equivalent to Pointers.


In C you use the concept of pointers whereas there are no pointers used in JAVA why?

Pointers in C are generally the thing that gives learners the most trouble. When C code is not written correctly with respect to pointer use, the resulting bugs can often be very difficult to find and correct. On the other hand, pointers are absolutely necessary in some cases.The designers of Java wanted to make programming easier and hence avoided adding pointers to the language. Java does have object references which accomplish much of what pointers accomplish albeit in a safer way.


Why java does not support pointer concepts?

Because java provides a secure platform and use of pointers in any language makes it insecure by various means. Keep in mind that one of Java's main design principles was to produce much simpler code than C/C++. Anyone who has ever looked through a bit of code and seen something like *(*(*p)(int))[10] will certainly agree that pointers, while useful, are often misused and can lead to overly complicated code. Java's concept of references in place of pointers has always been sufficient for this contributor.


Do other programming languages implement pointers?

All programming languages implement pointers, but not all languages allow low-level access to memory through a raw pointer. Java, for instance, uses resource handles and smart pointers rather than raw pointers, however the actual allocation of memory is handled by the Java virtual machine (JVM) so there is no need for low-level raw pointers.


How pointers are used in java?

They aren't. Java uses the (safer) idea of references instead of pointers.


What is the difference between c plus plus and java programming?

Java doesn't have pointers. C++ has pointers.