Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to check double value is empty or not

Tags:

java

json

android

i'm trying to get Double value from json, i want to ask how to check double value is empty or not?

this is how i initial it private static

final String kartu_xcord = "xcord";
    private static final String kartu_ycord = "ycord";
    ouble xcord,ycord;

this is how i parse my json:

xcord = c.getDouble(kartu_xcord);
ycord = c.getDouble(kartu_ycord);

this is how i try to check xcord is null or empty :

if (xcord.isNaN()) {
            LinlayNoMap.setVisibility(View.VISIBLE);
        } else {
            linlaymap.setVisibility(View.VISIBLE);
}

i hope someone can help me to solve my proble thank you

like image 200
Aoyama Nanami Avatar asked Oct 02 '13 09:10

Aoyama Nanami


People also ask

Can a double value be null?

Java primitive types (such as int , double , or float ) cannot have null values, which you must consider in choosing your result expression and host expression types.

How do you check if a value is blank?

Sometimes you need to check if a cell is blank, generally because you might not want a formula to display a result without input. In this case we're using IF with the ISBLANK function: =IF(ISBLANK(D2),"Blank","Not Blank")

How do you know if its null or empty?

You can use the IsNullOrWhiteSpace method to test whether a string is null , its value is String. Empty, or it consists only of white-space characters.


3 Answers

In java double is a primitive type which can not be null, There is Double wrapper class in java which can be checked as null.

Declare your coords of type Double not double and check if Double value is null.

like image 51
nsgulliver Avatar answered Sep 19 '22 22:09

nsgulliver


In Java double cannot be null.

like image 40
Arash GM Avatar answered Sep 22 '22 22:09

Arash GM


It can't be null or empty. It's a double value. Maybe try the Double wrapper?

like image 44
Kayaman Avatar answered Sep 22 '22 22:09

Kayaman