📄 stringtonumber.java
字号:
//Copyright (c) 1998, Arthur Gittleman
//This example is provided WITHOUT ANY WARRANTY either expressed or implied.
/* Illustrates wrapper classes used to convert
* a string to an int or a double, and the number format
* exception when the string has an invalid format.
*/
public class StringToNumber {
public static void main(String [] args) {
try {
int i = new Integer("435").intValue();
System.out.println("i = " + i);
int j = new Integer("45.2").intValue();
System.out.println("j = " + j);
}catch(NumberFormatException e) {
e.printStackTrace();
}
double d = new Double("3.14").doubleValue();
System.out.println("d = " + d);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -