Java.lang.NullPointerException NULL pointer problem

Source: Internet
Author: User


It is inevitable for an Android novice to encounter a null pointer problem. For example, when debugging a program on the appearance of "I'm sorry!" ' XXX ' has stopped running! "This is a representation of a null pointer.

Why is there a null pointer?

The so-called null pointer exception is because the property or method is called with null (NULL).
Null means there is no such object, since there is no such object, then to invoke his properties and methods, it will report an exception.
<--is mainly for the following reasons:
1. Uninitialized variables are used (although declared)
2. Uninitialized objects are used (although declared)
3. Use a keyword or an existing class name variable object method or class names.
This exception is thrown when an application attempts to use null where the object is needed.
<--This situation includes:
Invokes an instance method of a null object.
A field that accesses or modifies a null object.
Use NULL as an array to get its length.
Use NULL as an array to access or modify its time slice.
Throws null as the Throwable value.
(The above points to understand, and then look at your code, will definitely find out)

Now that you know why you're wrong, you have to see where it went wrong. See Logcat

Look closely at Logcat and you will find a mistake. Like what

Warning: Problem parsing stream-java.lang.nullpointerexceptionjava.lang.nullpointerexception<span style= "color:# ff0000; " > at Com.semaphore.util.plist.PElementAdapter.get (pelementadapter.java:25) at Com.semaphore.util.plist.PList.get (plist.java:25) at Com.semaphore.util.plist.PElementAdapter.getPath ( pelementadapter.java:31) </span> at Com.semaphore.TinyLoader.findLibs (tinyloader.java:76) at Com.semaphore.TinyLoader.main (tinyloader.java:37) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) At Sun.reflect.NativeMethodAccessorImpl.invoke (Unknown Source) at Sun.reflect.DelegatingMethodAccessorImpl.invoke ( Unknown source) at Java.lang.reflect.Method.invoke (Unknown source) at Com.exe4j.runtime.LauncherEngine.launch ( Unknown source) at Com.exe4j.runtime.WinLauncher.main (Unknown source)
from the above 3rd, 4, 5 is easy to see the Pelementadapter.java in the 25, 31 lines, plist in the 25th line, etc. there are errors. Specific errors to find themselves.

Java.lang.NullPointerException NULL pointer problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.