Linked Questions

160 votes
8 answers
539k views

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) { ...
K'''s user avatar
  • 5,298
43 votes
5 answers
41k views

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 ...
Robin's user avatar
  • 577
47 votes
3 answers
914k views

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: ...
Justin k's user avatar
  • 1,104
34 votes
9 answers
67k views

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; ...
marjasin's user avatar
  • 351
24 votes
1 answer
79k views

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 ...
Vitalii Romaniv's user avatar
31 votes
3 answers
238k views

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....
Steve's user avatar
  • 1,163
47 votes
1 answer
508k views

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....
ryckiazai's user avatar
  • 481
31 votes
3 answers
173k views

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 ...
George's user avatar
  • 367
14 votes
2 answers
73k views

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 ...
rapidclock's user avatar
  • 1,707
13 votes
2 answers
99k views

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 ...
Ivan Cristobal's user avatar
14 votes
1 answer
454k views

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:...
Roshan's user avatar
  • 143
21 votes
4 answers
94k views

I'm very new to Java 8 lambdas and stuff. I want to write a lambda function that takes a JSONArray, goes over its JSONObjects and creates a list of values of certain field. For example, a function ...
CrazySynthax's user avatar
  • 15.3k
13 votes
1 answer
40k views

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 ...
UsefulUserName's user avatar
16 votes
1 answer
21k views

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.view....
snowparrot's user avatar
15 votes
1 answer
31k views

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: ...
skm's user avatar
  • 609

15 30 50 per page
1
2 3 4 5
691