- 雙語版Java程序設(shè)計(jì)
- 何月順主編
- 182字
- 2018-12-27 20:14:15
3.12 Sample Program Practice
Example 3.1
//擴(kuò)展精度 class typetest { public static void main (String args[]) { long bigInteger = 98765432112345678L; float realNo = bigInteger; System.out.println(bigInteger); System.out.println(realNo); } }
Example 3.2
//顯式轉(zhuǎn)換 class typetest2 { public static void main(String args[]) { byte b = 0; char c = 'A'; short s = 0; int i = 0; long l = 0L; float f = 0.0F; double d = 0.0; f = l; l = (long)f; d = b; b = (byte)s; s = (short)c; c = (char)s; b = (byte)c; b = (byte)s; c = (char)b; i = b; System.out.print (……what ever you want to print here); } }
Example 3.3
//十六進(jìn)制的轉(zhuǎn)換 public class Tester { public static void main(String[] args) { short s1 = 0x1234; int i1 = 0x0000abcd; byte b1; b1 = (byte)s1; System.out.println("s1=" + s1 + ", b1=" + b1); s1 = (short)i1; b1 = (byte)s1; System.out.println("i1=" + i1 + ", s1=" + s1 + ", b1=" + b1); } }
推薦閱讀
- Practical Ansible 2
- R Data Mining
- 傳感器技術(shù)實(shí)驗(yàn)教程
- Moodle Course Design Best Practices
- 人工智能實(shí)踐錄
- 電腦主板現(xiàn)場維修實(shí)錄
- Linux服務(wù)與安全管理
- 學(xué)會(huì)VBA,菜鳥也高飛!
- 網(wǎng)絡(luò)安全管理實(shí)踐
- Extending Ansible
- 手機(jī)游戲策劃設(shè)計(jì)
- PowerMill 2020五軸數(shù)控加工編程應(yīng)用實(shí)例
- 基于Proteus的PIC單片機(jī)C語言程序設(shè)計(jì)與仿真
- Effective Business Intelligence with QuickSight
- PyTorch深度學(xué)習(xí)