📄 displayresult.java
字号:
public class DisplayResult {
public DisplayResult(String input) {
try {
float in = Float.parseFloat(input);
Squared sq = new Squared(in);
float result = sq.value;
System.out.println("The square of " + input + " is " + result);
} catch (NumberFormatException nfe) {
System.out.println(input + " is not a valid number.");
}
}
class Squared {
float value;
Squared(float x) {
value = x * x;
}
}
public static void main(String[] arguments) {
if (arguments.length < 1) {
System.out.println("Usage: java DisplayResult number");
} else {
DisplayResult dr = new DisplayResult(arguments[0]);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -