sampleconversions.java

来自「《A first book of java》by Gary J.Bronson 」· Java 代码 · 共 22 行

JAVA
22
字号
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 + =
减小字号Ctrl + -
显示快捷键?