Java基礎資料型別 (Elementary Data Type)

來源:互聯網
上載者:User

標籤:

Java共有8種基礎資料型別 (Elementary Data Type),如下:

  • 整形:int, byte,short, long
  • 浮點類型:float, double
  • 布爾類型:boolean
  • 字元類型:char

表一  基礎資料型別 (Elementary Data Type)

類型

位元組數

位元

取值範圍

舉例

byte

1

8

-27~27-1的整數

-128,54,127

short

2

16

-215~215-1的整數

1348,6543

int

4

32

-231~231-1的整數

0,-1000,345678

long

8

64

-263~263-1的整數

987657897,-12

float

4

32

-231~231的整數

23.978,87F

double

8

64

-263~263的整數

2.0231,0.435D

char

2

16

-215~215的整數

400,A,z,x,-23

boolean

1

8

true,false

true

 

 注意:(1)、Java沒有無符號類型(unsigned)。

    (2)、雙引號則表示一個字串,它是Java的一個物件類型String,並不是資料類型。

    (3)、布爾類型只有兩個值,整形值和布爾值不能相互轉換。

Java基礎資料型別 (Elementary Data Type)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.