字符串到文本输出

Con*_*att 0 java if-statement

这似乎是一个愚蠢的问题.如何打印if语句?

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

Ale*_* C. 5

您需要将高度转换为整数.然后,您将能够在if语句中进行比较.

int height = Integer.parseInt(heightCm.getText());
Run Code Online (Sandbox Code Playgroud)