第三講 Java 基礎資料型別 (Elementary Data Type)+運算子

來源:互聯網
上載者:User

第三講 Java 基礎資料型別 (Elementary Data Type)+運算子

  1. 常用基礎資料型別 (Elementary Data Type)
    • byte 一個位元組 取值範圍: -128 到 127
    • short 兩個位元組 取值範圍: -32768 到 32767
    • int 四個位元組 取值範圍: -2147483648 到 2147483647
    • long 八個位元組 取值範圍: ...
      • 注意:基礎資料型別 (Elementary Data Type)位元組數和取值範圍計算公司-(2^(位元組*8-1)) 到 (2^(位元組*8-1))-1
  2. 請思考:
    1. int teest1 = 'a'+'b';
    2. char test2 = 'a'+'b';
    3. char test3 = '中';
    • 結論:在 java 中,對 char 進行運算的時候,直接當作 ascii 碼對應的認證來對待。
  3. 思考:
    1. int a = 3;
    2. int b = a+3.4f+5.4;
    • 結論:當一個整數和一個 double 運算時,運算結果自動向高精度轉換。

聯繫我們

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