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

📄 stringtonumber.java

📁 Java 入门书的源码
💻 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 + -