Skip to content
Advertisement

Why the if condition runs the other way

the value passed fromjsonObject.getString("firstName"); to firstNameValidateUser is null as it doesn’t have any value, I need to run the following code which contain String firstName=jsonObject.getString("firstName");.... till returnedUser = new User(firstName, lastName, user.userName, user.password, birthDate, position,qualification,email); when the value of firstNameValidateUser is null. How do I check it,I have used the if condition to check if the firstNameValidateUseris null ,but from the output it seems like it is working the other way round. Is there something wrong with my if condition, or if I have done any other mistake please notify me.. please help me to fix this. Thank you in advance.

JavaScript

Advertisement

Answer

The most easiest way to check is using native API

JavaScript

Refer to android API http://developer.android.com/reference/org/json/JSONObject.html#isNull(java.lang.String)

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement