⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sampleconversions.java

📁 《A first book of java》by Gary J.Bronson 北大出版社
💻 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 + -