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

📄 castingnumbers.java

📁 j2me手机软件开发教学系列
💻 JAVA
字号:
//: c03:CastingNumbers.java
// What happens when you cast a float
// or double to an integral value?
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
import com.bruceeckel.simpletest.*;

public class CastingNumbers {
  static Test monitor = new Test();
  public static void main(String[] args) {
    double
      above = 0.7,
      below = 0.4;
    System.out.println("above: " + above);
    System.out.println("below: " + below);
    System.out.println("(int)above: " + (int)above);
    System.out.println("(int)below: " + (int)below);
    System.out.println("(char)('a' + above): " +
      (char)('a' + above));
    System.out.println("(char)('a' + below): " +
      (char)('a' + below));
    monitor.expect(new String[] {
      "above: 0.7",
      "below: 0.4",
      "(int)above: 0",
      "(int)below: 0",
      "(char)('a' + above): a",
      "(char)('a' + below): a"
    });
  }
} ///:~

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -