java四類八種

來源:互聯網
上載者:User

標籤:pre   位元組   e30   false   day01   des   date   width   name   

四類

八種

位元組數

資料表示範圍

整型

byte

1

-128~127

short

2

-32768~32767

int

4

-2147483648~2147483648

long

8

-263~263-1

浮點型

float

4

-3.403E38~3.403E38

double

8

-1.798E308~1.798E308

字元型

char

2

表示一個字元,如(‘a‘,‘A‘,‘0‘,‘家‘)

布爾型

boolean

1

只有兩個值true與false

 

 1 package day01; 2  3 /** 4  * @author mayi 5  * @date 2018年5月1日 下午4:30:13 6  *  7  * @project_name javaStudy 8  * @package_name day01 9  * @file_name Variabe.java10  * @description 11  */12 public class Variabe {13 //        定義Java中的變數14 //       定義出所有資料類型的變數15 //       四類八種16         public static void main (String[] args) {17                 //定義整數類型,位元組類型 byte類型18                 //記憶體中1個位元組, -128 12719                 byte b = 100;20                 System.out.println(b);21                 22                 //定義整數類型,短整型, short類型23                 //記憶體中2個位元組, -32768 3276724                 short s = 200;25                 System.out.println(s);26                 27                 //定義整數類型, 整型, int類型28                 //記憶體中4個位元組, -2147483648  214748364729                 int i = 500006;30                 System.out.println(i);31                 32                 //定義整數類型, 長整型, long類型33                 //記憶體中8個位元組34                 long l = 21474836407L;35                 System.out.println(l);36                 37                 //定義浮點數據, 單精確度 float類型38                 //記憶體中4個位元組39                 float f = 1.0F;40                 System.out.println(f);41                 42                 43                 //定義浮點數據, 雙精確度 double類型44                 //記憶體中8個位元組45                 double d = 2.2;46                 System.out.println(d);47                 48                 //定義字元類型, char49                 //記憶體中2個位元組, 必須單引號包裹,只能寫1個字元50                 char c = ‘m‘;51                 System.out.println(c);52                 53                 //定義布爾類型, boolean54                 //記憶體中1個位元組, 資料值, true false55                 boolean bool = true;56                 System.out.println(bool);57         }58 }

 

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.