public class HelloWorld { public static void main(String[] args) { // 定義int類型變量,值為86 int score1 = 86; // 創建Integer包裝類對象,表示變量score1的值 Integer score2=new Integer(score1); // 將Integer包裝類轉換為double類型 double score3=score2.doubleValue(); // 將Integer包裝類轉換為float類型 float score4=score2.floatValue(); // 將Integer包裝類轉換為int類型 int score5 =score2.intValue(); System.out.println("Integer包裝類:" + score2); System.out.println("double類型:" + score3); System.out.println("float類型:" + score4); System.out.println("int類型:" + score5); } }

noprom
2014-08-22
舉報
0/150
提交
取消