Int與Integer的區別

一、區別: 1.Integer是int的包裝類,int則是java的一種基本的數據類型; 2.Integer變量必須實例化之後才能使用,而int變量不需要實例化; 3.Integer實際是對象的引用,當new一個Integer時,實際上生成一個指針指向對象,而int則直接存儲數值 4.Integer的默認值是null,而int的默認值是0。 二、Integer和int的比較   1.由於Integ
相關文章
相關標籤/搜索