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