android: String value match another String value using operand == not working?

前端 未结 5 428
生来不讨喜
生来不讨喜 2021-01-16 20:29

Hopefully this is an easy fix, but for the moment is is boggling me (Actionscript programmer new to Java programming).

I have a string variable coming from getExtra

5条回答
  •  北海茫月
    2021-01-16 21:09

    Strings are Objects, and to do correct Object equality comparisions, you need to use

    dir.equals("content");
    

    or better yet (to avoid possible null pointer exceptions)

    "content".equals(dir);
    

提交回复
热议问题