Java編程思想 第4版 練習題 / 第2章 一切都是對象 / 練習9

// TIJ4 第2章 一切都是對象, 練習 9, 第 90 頁;
// 編寫一個程序,展示自動包裝功能對所有的基本類型和包裝器類型都起作用。


//......
public class BoxingTest{
public static void main(String[] args){
boolean b = false;
char c = 'x';
byte t = 8;
short s = 16;
int i = 32;
long l = 64;
float f = 0.128f;
double d = 2.56;
Boolean B = b;
System.out.println("boolean b = "+ b);
System.out.println("Boolean B = "+ B);
Character C = c;
System.out.println("char c = "+ c);
System.out.println("Character C = "+ C);
Byte T = t;
System.out.println("byte t = "+ t);
System.out.println("Byte T = "+ T);
Short S = s;
System.out.println("short s = "+ s);
System.out.println("Short S "+ S);
Integer I = i;
System.out.println("int i = "+ i);
System.out.println("Integer I = "+ I);
Long L = l;
System.out.println("long l = "+ l);
System.out.println("Long L = "+ L);
Float F = f;
System.out.println("float f = "+ f);
System.out.println("Float F = "+ F);
Double D = d;
System.out.println("double d = "+ d);
System.out.println("Double D = "+ D);
}
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章