Linked Questions

55 votes
6 answers
17k views

I need to check if some value is null or not. And if its not null then just set some variable to true. There is no else statement here. I got too many condition checks like this. Is there any way to ...
user avatar
21 votes
4 answers
14k views

I find myself constantly writing this statement MyObject myObject = something.getThatObject(); if( myObject !=null && myObject .someBooleanFunction()){ } in order to prevent a null ...
Carlos Bribiescas's user avatar
6 votes
4 answers
3k views

Possible Duplicate: How to avoid “!= null” statements in Java? Share your thoughts..
Student's user avatar
  • 28.6k
6 votes
2 answers
16k views

I have some data in input that I'll have to use to set all properties of a POJO. The POJO might be partially set. My problem is to set the property only if related input data is not null. I know I can ...
user3138984's user avatar
17 votes
4 answers
7k views

I am writing codes that query the database to get the data. There are some classes that consist of Lists, but sometime the list or other attribute can not be initiated and their value is null, so I ...
ssj's user avatar
  • 1,817
-6 votes
6 answers
3k views

What is the best way to avoid multiple if blocks which is used for null checks in Java? The following is my sample code. Which one is the most optimized way? if (address!=null} { if (firstName!=...
Chinnu's user avatar
  • 59
4 votes
4 answers
27k views

I am a junior developer and I use java to do website development. I know org.apache.common.lang.StringUtils is recommended because of its null safty. But what is null safe or null safty exacty? why ...
GsM's user avatar
  • 161
0 votes
2 answers
21k views

I know that NULL check for every arguments in a public API is good practice in java. But just curious, do we need do such NULL check in the front of all methods. There are definitely values for doing ...
Alfred's user avatar
  • 1,881
-2 votes
4 answers
23k views

How to avoid null insertion in ArrayList while inserting element? ArrayList<String> al=new ArrayList<String>(); al.add(null);//should avoid . . . al.add("Ramesh");
Ramesh Basantara's user avatar
0 votes
6 answers
10k views

public class Test { //required fields private String str1; private String str2; //optional private Calendar cal; public Test(String a, String b){ str1 = a; ...
vjk's user avatar
  • 2,293
12 votes
0 answers
6k views

I am trying to build a geofencing app using Kotlin in the android studio but the VM crashed then the next run show this error E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.mapgis, PID: ...
Sarah HH's user avatar
  • 121
0 votes
1 answer
3k views

I'd like to to make possible that layout with options to change the background color of MainActivity. I don't know how to do this- how tell the program to change the background color of other view, in ...
Inkwizytor's user avatar
6 votes
2 answers
2k views

I'm getting some crash reports about a NullPointerException happening in StaggeredGridLayoutManager. Looks like around 10% of my users are suffering this issue. I have a very basic RecyclerView with ...
Miguel Botón's user avatar
0 votes
1 answer
2k views

I have been trying lately but I just can't find where is the null object, help me understanding this error: 2021-01-24 01:10:47.244 24211-24211/com.salmanibrahim.firebasechat E/AndroidRuntime: FATAL ...
Salman Malik's user avatar
  • 1,145
2 votes
2 answers
402 views

Can any Java proficient / expert suggest me what is the optimistic way of checking null reference or objects before using it to avoids NullPointerException? In my code I've more than 100 fields and ...
user avatar

15 30 50 per page
1
2 3 4 5
12