張佑維java data type資料型態

/*張佑維2022/10/24,Java data type,資料型態*/
public class Main {
  public static void main(String[] args) {
    int myNum = 5;               //宣告整數integer (whole number),4位元組bytes
    float myFloatNum = 5.99f;    //浮點數=實數,floating point number,4位元組bytes
    double doubleNum=5.99d;      //倍精數,8位元組,8bytes,和long長整數
    char myLetter = 'D', littlePig='g';  //*字元character=角色,2位元組bytes=16位元bits
    boolean myBool = true;       //布林boolean,1位元bit,0或1,false or true
    String myText = "張佑維";    //  字串String,非原型資料,長度變動的
    System.out.println(myNum);  //系統的.輸出的.列印print且換列ln=line
System.out.println(myFloatNum);System.out.println(myLetter);System.out.println(myBool); System.out.println(myText); myNum = myLetter; System.out.println(myNum);
    System.out.println(myLetter);
    System.out.println(myBool);
    System.out.println(myText);
    myNum=littlePig;System.out.println(myNum);
    for (int k=1; k <10; k=k+3)
       System.out.print(k + " ");
  }
}

挪威w3schools資料型態data type截圖

在撰寫模式拷貝表格


資料型態長度(位元組)範圍最小範圍最大
位元數1位元組=8位元-128127
短整數2位元組=16位元-32,76832,767
整數4位元組=32位元-2,147,483,6482,147,483,647
長整數8位元組=64位元-9,223,372,036,854,780,0009,223,372,036,854,780,000
浮點數4位元組=32位元1.4*10^-453.4*10^38
倍精數8位元組=64位元4.9*10^-3243.4*10^308
布林1位元falsetrue
字元2位元組=16位元'\u0000''\uffff'

資料型態長度(位元組)記憶體
位元數byte1位元組=8位元bbbbbbbb
短整數short2位元組=16位元bbbbbbbb.bbbbbbbb
整數4位元組=32位元bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb
長整數8位元組=64位元bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb
浮點數4位元組=32位元bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb
倍精數8位元組=64位元bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb
布林1位元b
字元2位元組=16位元bbbbbbbb.bbbbbbbb

在html模式拷貝表格

資料型態長度(位元組)範圍最小範圍最大
位元數1位元組=8位元-128127
短整數2位元組=16位元-32,76832,767
整數4位元組=32位元-2,147,483,6482,147,483,647
長整數8位元組=64位元-9,223,372,036,854,780,0009,223,372,036,854,780,000
浮點數4位元組=32位元1.4*10^-453.4*10^38
倍精數8位元組=64位元4.9*10^-3243.4*10^308
布林1位元falsetrue
字元2位元組=16位元'\u0000''\uffff'

資料型態長度(位元組)記憶體
位元數byte1位元組=8位元bbbbbbbb
短整數short2位元組=16位元bbbbbbbb.bbbbbbbb
整數 4位元組=32位元bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb
長整數8位元組=64位元bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb
浮點數4位元組=32位元bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb
倍精數8位元組=64位元bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb
布林1位元b
字元2位元組=16位元bbbbbbbb.bbbbbbbb

Java MIN_VALUE MAX_VALUE

留言

這個網誌中的熱門文章

張佑維python,print,input,字串方法[::-1]

張佑維Entry輸入文字變數textvariable字型font