PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 23, 2022

[FIXED] how to check double value is empty or not

 July 23, 2022     android, java, json     No comments   

Issue

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


Solution

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.



Answered By - nsgulliver
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing