jeudi 30 août 2018

Odd IF behavior

UPDATE:

using:

listTransactions.getStatus().equals("PENDING")

seems to work. But why doesn't it work the other way? I admit I'm newish to Java coming from C# but this is as elementary as it gets. Does Java not use "==" with Strings?


Hello,

In the below snippet:

Log.d("test",listTransactions.getType()+" "+listTransactions.getStatus());
    if(listTransactions.getType()==2 && listTransactions.getStatus()=="PENDING")

    {
        Log.d("test2","WORKING");
    }

the Log.d output is

D/test: 2 PENDING

but for some reason the code inside IF does not evaluate.

getType() returns int and getStatus() returns String.

I've spent the last half hour trying to re-write it with the same result. What could be causing this?

Many thanks for your time.

Aucun commentaire:

Enregistrer un commentaire