2012-07-15 100 views
-1

可能重复:
How do I compare strings in Java?为什么字符串不能在“if子句”中使用?

我有2类,让说的A.class和b.class

,我想从发送数组b。使用意图,在一个类别

Intent intent = new Intent(this,b.class); 
intent.putExtra("stringtext", "1"); 
startActivity(intent); 

和在b.class我捕获的意图价值e为这个

Intent it = getIntent(); 
String id = it.getStringExtra("stringtext"); 

当我尝试打印ID,它给我的“1” 但是当我使用的ID中,如果从句我没有工作,我尝试这个

if(id=="1") 
{ 
teks.setText("its one"); 
} 
else 
{ 
teks.setText("not one"; 
} 

怎么可能这件事?

回答

相关问题