包裝類的轉(zhuǎn)換
int score1=58;
Integer score2=new Integer(score1);
double ?score3=score2.doubleValue();
float score4=score3.floatValue();
int score5=score4.intValue();
為什么不能將double包裝類轉(zhuǎn)換成float包裝類,float也不能轉(zhuǎn)換成int包裝類
int score1=58;
Integer score2=new Integer(score1);
double ?score3=score2.doubleValue();
float score4=score3.floatValue();
int score5=score4.intValue();
為什么不能將double包裝類轉(zhuǎn)換成float包裝類,float也不能轉(zhuǎn)換成int包裝類
2017-05-01
舉報
2017-09-25
對象.方法名 調(diào)用方法,你這個score2是int類型對象,不是double類型的,無法使用doubleValue()方法
2017-05-01
score2是包裝類,轉(zhuǎn)化為double類賦值給score3,score3依舊是基本類,不具備包裝類方法的調(diào)用
2017-05-01
應(yīng)該不行吧,要轉(zhuǎn)換的話只能轉(zhuǎn)換到對應(yīng)的包裝類在轉(zhuǎn)