Android Question Error while trying to compare string to Null

Makumbi

Well-Known Member
Licensed User
Please help when i try to compare Null to as string value taking that value as Null then i recieve the error below please help
B4X:
'ProgressDialogShow2("Loading Results Current Performance Please Wait...",False)
        If hold="null" Then
        
            StartActivity(Academics)
        End If

B4X:
Froms: /Date(1578258000000)/
Tos: /Date(1580850000000)/
06/01/2020
06/01/2020
05/02/2020
05/02/2020
result: null
Error occurred on line: 736 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at com.kccug.kabojjajuniorapp.main$ResumableSub_CustomListView1_ItemClick.resume(main.java:4927)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1761)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
 

rosippc64a

Active Member
Licensed User
Longtime User
you can write like this:
B4X:
If hold=null Then
in this case you compare a string not with an another string what contains "null", but a null value!
 
Upvote 0
Top