Linked Questions
10,375 questions linked to/from What is a NullPointerException, and how do I fix it?
155
votes
8
answers
488k
views
Does java.util.List.isEmpty() check if the list itself is null? [duplicate]
Does java.util.List.isEmpty() check if the list itself is null, or do I have to do this check myself?
For example:
List<String> test = null;
if (!test.isEmpty()) {
for (String o : test) {
...
43
votes
5
answers
40k
views
NullPointerException on getActivity().runOnUiThread(new Runnable(){ [duplicate]
I know there are many different causes for NPE but mine is slightly weird (At least to me).
So I have converted my Activities to Fragments successfully, but my problem appears to be coming from the ...
48
votes
3
answers
879k
views
How to solve java.lang.NullPointerException error? [duplicate]
When I run my Java program, it gives me an error on this line
compiler.getTask(null, null, new DiagnosticCollector<JavaFileObject>(), null, null, compilationUnits);
Error I am getting is:
...
34
votes
9
answers
65k
views
NullPointerException when Creating an Array of objects [duplicate]
I have been trying to create an array of a class containing two values, but when I try to apply a value to the array I get a NullPointerException.
public class ResultList {
public String name;
...
24
votes
1
answer
77k
views
Attempt to invoke interface method 'boolean java.util.List.add(java.lang.Object)' on a null object reference [duplicate]
MainActivity.java has following code:
package com.softjourn.redmineclient.activities;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import ...
30
votes
3
answers
227k
views
NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equalsIgnoreCase(java.lang.String)' on a null object reference [duplicate]
I am getting this error at runtime.
java.lang.RuntimeException: Unable to start activity ComponentInfo
java.lang.NullPointerException: Attempt to invoke virtual method
'boolean java.lang.String....
47
votes
1
answer
494k
views
java.lang.NullPointerException: Attempt to invoke virtual method on a null object reference [duplicate]
I am trying to save player's name in shared preference and make it display in another activity by getting it again in shared preference but my app crash.
FATAL EXCEPTION: main
Process: plp.cs4b....
31
votes
3
answers
172k
views
- java.lang.NullPointerException - setText on null object reference [duplicate]
This is what I'm trying to do for several hours:
I've got a MainActivity.java file (listing below) and a fragment_start.xml file with a start button. Tapping the start-button should display the ...
14
votes
2
answers
72k
views
NullPointerException when adding an object to ArrayList in Android [duplicate]
I'm trying to create a List View with BaseAdapter and i keep getting a Null Object Reference Error at the point of adding an object to an ArrayList.
Relevant code is below:
public class MainActivity ...
11
votes
3
answers
92k
views
android - Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference [duplicate]
I'm trying to set the text of the navigation drawer activity from the fetched data on my database, but when i try to do so, it throws the following error
Attempt to invoke virtual method 'void ...
13
votes
1
answer
438k
views
How can I solve Exception in thread "main" java.lang.NullPointerException error [duplicate]
I am having a problem at a Java program. Exception in thread "main"
java.lang.NullPointerException
at twoten.TwoTenB.<init>(TwoTenB.java:29)
at javapractice.JavaPractice.main(JavaPractice.java:...
16
votes
1
answer
20k
views
NullPointerException while setting LayoutParams [duplicate]
I want to add a button programmatically, which LayoutParams should be set too.
Unfortunaly the app gives an exception:
java.lang.NullPointerException: Attempt to write to field 'int
android....
10
votes
1
answer
33k
views
Using removeif on a hashmap [duplicate]
I am trying to remove entries from a Hashmap, if i have already used them. Sadly, I'm not familier with Java 8 lambda expressions, so I'm not sure how to remove the entries correctly. Could somebody ...
15
votes
1
answer
31k
views
NullPointerException when trying to get URI with FileProvider(Android) [duplicate]
i want to take a Photo after clicking on a button. But i am getting NullPointerException when trying to get URI with FileProvider.
Here is my ErrorCode:
Caused by: java.lang.NullPointerException: ...
8
votes
4
answers
29k
views
How to rectify NullPointerException in v4.DrawerLayout? [duplicate]
I am trying to implement a navigation drawer but for some reasons am getting this null pointer exception.
I have spent a lot of time on it but in vain. This is a part of my code. I can't understand ...