Questions tagged [nullpointerexception]

The Java exception thrown when an application attempts to use null in a case where an object is required.

This Java is thrown when an application attempts to use null in a case where an object is required.

These include:

  • Calling the instance method of a null object.
  • Accessing or modifying the field of a null object.
  • Taking the length of null as if it were an array.
  • Accessing or modifying the slots of null as if it were an array.
  • Throwing null as if it were a Throwable value.
  • Unboxing of null object.

Applications should throw instances of this exception to indicate other illegal uses of the null object.

It's often abbreviated as NPE

Practically all questions with this tag are duplicates of the canonical What is a NullPointerException and how do I fix it?.

15961 questions
2
votes
1 answer

Internal error during run emulater in android

I encounter each time when try to run project. An internal error occurred during: "Launching Android_project_name". java.lang.NullPointerException
Horrorgoogle
  • 7,858
  • 11
  • 48
  • 81
2
votes
1 answer

NullPointerException when i call SmsManager.sendTextMessage() method

When this line is executed: val smsManager = context.getSystemService(SmsManager::class.java) I am getting this exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void…
devblock
  • 113
  • 7
2
votes
0 answers

Android Studio Null Pointer Exception on ArrayList using Intent

I am trying to create an intent with bundle extras but I am getting null pointer exception error on the Array List. Here is the error: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ArrayList…
2
votes
2 answers

How would I go about fixing a NullPointerException of the following code?

I have this code and when I run the script, I pass in valid parameters, but I keep on getting a NPE. Help? Code: private static Date getNearestDate(List dates, Date currentDate) { long minDiff = -1, currentTime = currentDate.getTime(); …
Dylan Wheeler
  • 6,928
  • 14
  • 56
  • 80
2
votes
0 answers

IDE Error when importing library in Android Studio

I want to import this library into my Android Project in Android Studio. I tried to do it this way So I cloned the library and did File > New > Import Module > Path to libstreaming but i get an IDE Fatal Error: Exception in Plugin…
2
votes
2 answers

Why list.contains(null) throwing null pointer exception?

I have List countriesList which contains Long values which are country ids. Now I am iterating over some List list by using streams. userRequests.stream(). forEach(userRequest-> { …
Mohsin M
  • 239
  • 7
  • 20
2
votes
4 answers

Exception in thread "main" java.lang.NullPointerException

I am a beginner in java programming. I am trying to develop a program but when I ran my program which is posted below and it came back with this error: Exception in thread "main" java.lang.NullPointerException at…
yana819
  • 31
  • 1
  • 3
2
votes
1 answer

Trying play audio file with JavaFX

I'm trying to play audio file in my JavaFX app, code look fine for me but I'm getting errors I think that the problem is in line 28: "Caused by: java.lang.NullPointerException: Cannot invoke "java.net.URL.toString()" because "resource" is null at…
2
votes
1 answer

child-class clone method throws null pointer exception

Can any of you offer help with my implementation of the clone method in the following toy classes? I've read through java documentation and essential java textbook and followed the instructions to no avail. The problem arises when I try to use the…
2
votes
1 answer

Android Studio Kotlin Null Pointer Exception while updating Firestore Database

I've recently stumbled upon a runtime error that crashes my application for whatever reason and I cannot get to the bottom of it. Basically I am updating user profile data by storing it in a hashmap. This is what the user class looks…
2
votes
2 answers

NullPointerException when using customized Autowired

I customized a Annotation @CustomizedAutowired like @Autowired by using BeanPostProcessor (InjectBeanPostProcessor.java), but I got a NullPointerException when AOP is used. Why it is null when using AOP? Why DemoController seems to be proxied twice…
2
votes
1 answer

Null exception @Service in a spring @RestController using constructor injection

This is my third personal spring-boot project, I am doing 99% same config than before so have no clue why I am getting this error on this one. The project startup just well but once I do any petition on the unique @RestController I have, it…
Woodsoul
  • 155
  • 1
  • 10
2
votes
2 answers

java hashmap nullpointer outside of netbeans

I have the following code in netbeans (using javafx in the same project): public class ExperimentControler { public static HashMap userInput = null; public static ObservableMapWrapper userInputObservable = null;…
Stefanos Kalantzis
  • 1,619
  • 15
  • 23
2
votes
4 answers

Android nullpointerexception

To be short...I have a widget, you can see the important part below public class ExampleWidget extends AppWidgetProvider { private PhoneStateListener listener; private TelephonyManager telephonyManager; @Override public void onUpdate(Context…
user874649
2
votes
0 answers

android null pointer exception

I write a simple programm, but there is problem. Here is the code: package player.org; import android.app.Activity; import android.content.Intent; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import…
Vahag Vardanyan
  • 301
  • 6
  • 13