JAVA變數的類型,定義變數

來源:互聯網
上載者:User

標籤:

JAVA中常用的資料類型

資料類型 資料類型解釋 說明
char 字元型 用於儲存單個字元,如:性別“男”、“女”,電燈“開”、“關”
int 整形 用於儲存整數,如一天的時間是24小時,一月份是31天
double 雙精確度 用於儲存小樹,如蒙牛早餐奶的價格是1.3元,手機待機時間是6.5小時
String 字串 用於儲存一串字元,如“我的愛好是踢足球”,“我喜歡Java程式”

 

 

 

 

 

 

 

定義變數

public class Test{    public static void main(String[] args){        char a        =    ‘p‘;    //聲明並賦值字元型形(單個字元)的變數        int    number    =    123;    //聲明並賦值整形的變數        double    b    =    1.5;    //聲明並賦值雙精確度形的變數        String d    =    "zifuchuan";    //聲明並賦值字串型的變數        //輸出        System.out.println(a);        System.out.println(number);        System.out.println(b);        System.out.println(d);    }}

 

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.