2014-02-11 80 views
0

這可能看起來像一個愚蠢的問題。我如何使這個if語句打印?字符串到文本輸出

private void btnCheckMouseClicked(java.awt.event.MouseEvent evt) { 
     String height; 
     height = heightCm.getText(); 
     if ((height >=122) && (height <=188)){ 
      outputCheck.setText("WORKING..."); 
     } 
    } 
+1

將高度轉換爲整數。 'int height = Integer.parseInt(heightCm.getText());' –

+1

@ZouZou很好的捕獲 – 2014-02-11 22:09:47

回答

5

您需要將高度轉換爲整數。那麼你將能夠在你的if語句中進行比較。

int height = Integer.parseInt(heightCm.getText()); 
+1

它的工作,謝謝! –