JAVA封裝類

來源:互聯網
上載者:User

標籤:

1. java封裝類

封裝類對應表

基礎資料型別 (Elementary Data Type)

封裝類

byte

Byte

boolean

Boolean

short

Short

char

Character

int

Integer

long

Long

float

Float

double

Double

2. 封裝類賦值(values())

Intenger  integer1 = new Integer(100);// 建立一個Integer對象

Intenger  integer2 = 100;// 等同於如下values(100)

Integer   integer3 = Integer.values(100); // 取緩衝中的100的Integer對象,沒有則建立對象

 

在Integer中使用了IntegerCache類,用來緩衝-128-127 的Integer對象。 所以在-128-127 的數直接會取緩衝的Integer對象。

== 基本類型比較值, 對象比較地址, new 建立一個對象。

 

3. 緩衝對象

封裝類對應表

基礎資料型別 (Elementary Data Type)

封裝類

byte

Byte  (-128-127)

boolean

Boolean(比較字串)

short

Short(-128-127)

char

Character(0-128)

int

Integer(-128-127)可能根據配置擴大

long

Long(-128-127)

float

Float(無)

double

Double(無)

 

 

 

 4. hashcode(重寫)

封裝類hashcode返回 基本類型值

 

 5. equal(重寫)

封裝類equal比較的基本類型值

 

 

 

JAVA封裝類

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.