📄 stringtonumberdemo.java
字号:
package conversion;
public class StringToNumberDemo {
public static void main(String[] args) {
String string1 = "55";
byte byte1 = Byte.parseByte(string1);
string1 = "223";
short short1 = Short.parseShort(string1);
string1 = "2007";
int int1 = Integer.parseInt(string1);
string1 = "200701";
long long1 = Long.parseLong(string1);
string1 = "200701.09";
float float1 = Float.parseFloat(string1);
string1 = "12345.2345";
double double1 = Double.parseDouble(string1);
System.out.println("byte1 = " + byte1);
System.out.println("short1 = " + short1);
System.out.println("int1 = " + int1);
System.out.println("long1 = " + long1);
System.out.println("float1 = " + float1);
System.out.println("double1 = " + double1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -