2014-12-04 20 views
0

因此,我有一個小應用程序,並且我爲用戶輸入了「額外的」JTextField,以輸入「是」或「否」,如果他想要額外的數據。如果語句來自JTextField的字符串

我用這個方法:

process(file.getText(), Integer.parseInt(aText.getText()), 
        Integer.parseInt(bText.getText()), cText.getText(), 
        dText.getText()); //dText is the one I have problems with 

public void process(String name, int a, int b, String obs, String extra) { ... } 

我寫這

if(extra== "yes"){ 
      writer.write("Success!"); 
     } 

,但它無法正常工作。

如果我寫的只是

writer.write(extra); 

它會工作,通過這意味着它可以讀取文本I輸入,但仍無法使用if語句。 我做錯了什麼或者根本不可能?

這裏是我的全碼:http://pastebin.com/esw302uD

對不起我的英語不好。

回答

1

使用extra.equals("yes")而不是extra== "yes"

相關問題