網站首頁 美容 美體 服飾 情感 娛樂 生活
當前位置:哇咔範 > 生活 > 經驗

integer和int的區別 你會區別嗎

欄目: 經驗 / 發佈於: / 人氣:1.57W
integer和int的區別 你會區別嗎

1、Integer是int的包裝類,int則是java的一種基本數據類型 ;

2、Integer變量必須實例化後才能使用,而int變量不需要;

3、Integer實際是對象的引用,當new一個Integer時,實際上是生成一個指針指向此對象;而int則是直接存儲數據值;

4、Integer的默認值是null,int的默認值是0。

Tags:integer int