Ves*_*tel 2 java string integer
我正在尝试编写说明,以便在圆圈即将为12时注意,然后将1添加到正方形.
下面的代码对我来说很好
int x = Integer.parseInt(circle.getText());
x = x + 1;
String z = Integer.toString(x);
circle.setText(z);
Run Code Online (Sandbox Code Playgroud)
但是,我正在尝试编写这些新指令时遇到问题.我如何得到平方,转换为整数,加1然后将值放回去?
int q = Integer.parseInt(square.getText());
x = q + 1;
square.setText(x);
Run Code Online (Sandbox Code Playgroud)
您可以转换为String使用Integer.toString():
square.setText(Integer.toString(x));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13815 次 |
| 最近记录: |