即使输入值“d”,if语句也不会执行

时间:2015-12-21 15:54:42

标签: java android-studio

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_story);

        Intent intent = getIntent();
        String name = intent.getStringExtra("name");

        if (name == "d")
        {
            name = "Spike";
        }

        TextView heading = (TextView) findViewById(R.id.storyTextView);
        heading.setText("And our story begins with " + name);

0 个答案:

没有答案