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?.

15513 questions
2
votes
2 answers

Ternary operator for Bigdecimal null validation

Why am I getting null pointer exception in this code? BigDecimal test = null; String data = ""; try { System.out.println(test==null?"":test.toString()); data = test==null?"":test.toString(); System.out.println(data); data…
Dekso
  • 495
  • 2
  • 14
2
votes
1 answer

Quick Sort (compare to) in Java

This program cannot run but I don't know why: Abstract class public class Mahasiswa implements Comparable { private String nama; private int nim; public Mahasiswa(String nama, int nim) { } public String getNama() { …
2
votes
1 answer

Receiving NULL on response error body if the status code is 400 with retrofit in android

I was working on some login process and got stuck. The problem was when i enter a wrong password it always throws the NullPointerException because my getMessage was receiving null response from backend. After that what i did was i changed my status…
2
votes
1 answer

Avoid NullPointerException When JTable Exports to Excel File

I have a JTable with no values (empty columns data). Like this, |column 1|column 2|column 3|column 4| ------------------------------------- |Java |C# | |Ruby | ------------------------------------- |Java | |PHP |Ruby …
Hasitha Jayawardana
  • 2,152
  • 3
  • 14
  • 32
2
votes
0 answers

findViewHolderForAdapterPosition() always returns null for custom ViewHolder

So I'm having trouble getting the ViewHolder by adapter position. I'm using the LayoutManager to get the first completely visible item position, but when i call findViewHolderForAdapterPosition() it returns null. I'm also doing a check if postion is…
2
votes
0 answers

Why does Collectors.toMap require non null values

I am putting the results of a Java 11 stream into a Collectors.toMap(keyMapper, valueMapper) collector. It so happens that my value-mapper (lambda) returns a null value, resulting in a NullPointerException, which is…
Raedwald
  • 40,290
  • 35
  • 127
  • 207
2
votes
1 answer

Why is NullPointer Exception thrown in isSplitTypePreventInhibited when contents of table cell overflow to next page?

Issue In a Jasperreport, if the content of table detail cell or header cell is large to not fit in one page, a runtime NullPointer exception is thrown. This behavior is observed in both Jasperreports Studio as well as Jasperreports…
2
votes
3 answers

Error Null pointer. (io.reactivex.Scheduler)' on a null object reference

This is my log cat. When i click on specific tab, my app crashes. java.lang.NullPointerException: Attempt to invoke virtual method 'io.reactivex.Flowable io.reactivex.Flowable.observeOn(io.reactivex.Scheduler)' on a null object reference at…
Hamza Siddiqui
  • 237
  • 1
  • 8
2
votes
2 answers

SQLite SELECT MAX() query returns null to cursor?

I have a SQLite Table called "TBL_EVO" where I want to get the biggest value from column "DATE_MODIFIED". With following query I got the result in SQLite Browser like below. SELECT MAX(DATE_MODIFIED) FROM 'TBL_EVO'; When I run the query from code…
MSeiz5
  • 95
  • 1
  • 8
  • 28
2
votes
1 answer

Does android kill singleton in order to free memory?

I've got a very weird problem and is difficult to describe so please read carefully the assumptions before the answer to avoid jumping into something I already know isn't 1 - I've got an android app which login from my server 2 - after a successful…
Rafael Lima
  • 1,834
  • 21
  • 63
2
votes
0 answers

Nullpointerexception on com.android.okhttp.internal.http.HttpStream.writeRequestHeaders

FATAL EXCEPTION: main Process: nixerton.everemotequicktask, PID: 11611 java.lang.NullPointerException: Attempt to invoke interface method 'void …
Beter
  • 107
  • 1
  • 12
2
votes
0 answers

Exception: at android.graphics.drawable.AdaptiveIconDrawable.isProjected in Android OREO

I have an application in Play Store. I get NullPointerException everday in my application and I don't know where it come from. Because, logs do not contain any lines from classes i create. Could you please help me to find where it arise from? …
Burak
  • 1,099
  • 1
  • 9
  • 14
2
votes
3 answers

For loop to search through 2D array in Java returns NullPointerException

For a project at University, I have to create a game of Tic Tac Toe. I have this for loop with if statements to search through the 2D array of 3x3 size, and return if it's either X or O (enum). That results in showing which side has won the…
Abdullah
  • 49
  • 5
2
votes
2 answers

If Any field value of @EmbeddedId is null, which problem will arise?

I am fetching a problem with Hibernate @EmbeddedId. Code of my @EmbeddedId is: @Embeddable public class EnrolRegEmbededId implements Serializable { @Column(name="ENROL_NO") private String enrolNo; @Column(name="REG_NO") private String regNo; } My…
2
votes
1 answer

Why do I get a null pointer exception while passing the data from activity to fragment?

Here is my main activity where I want to pass the cityname's text to my TabFragment1 .I am getting null pointer exception.Please help me out in resolving the issue.Even transaction commit () is not solving the problem,Is anything wrong with the…
1 2 3
99
100