📄 sampleconversions.java
字号:
public class SampleConversions
{
public static void main(String[] args)
{
String numstring = "12345";
int num;
double dnum;
// convert to an integer and perform a numerical operation
num = Integer.parseInt(numstring);
System.out.println("The string \"" + numstring
+ "\" as an integer number is: " + num);
System.out.println("This number divided by 3 is: " + (num / 3));
// convert to a double and perform a numerical operation
numstring = numstring + ".96"; // concatenate to the original string
dnum = Double.parseDouble(numstring);
System.out.println("\nThe string \"" + numstring
+ "\" as a double number is: " + Double.toString(dnum));
System.out.println("This number divided by 3 is: " + (dnum / 3));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -