楊朝淞Java資料型態

挪威w3schools.com練習Java code

/*楊朝淞2022/10/24Java變數variable資料type型態*/
public class Main {
  public static void main(String[] args) {
    int i;                    /*註解java, JavaScript, CSS*/
    int myNum = 5;            //宣告整數integer(whole number)
    float myFloatNum = 5.99f; //宣告浮點數floating point number, 4 bytes=32 bits,4位元組
    char myLetter = '龍';     //宣告字元character, 2 bytes=16 bits,2位元組
    boolean myBool = true;    //宣告布林boolean, 1 bit,1位元
    String myText = "楊朝淞";  //宣告字串String
    i = myLetter;             //整數i=字元'龍'
    System.out.println(myLetter + "字碼unicode 10進位" + i);
    System.out.println(myNum);
    System.out.println(myFloatNum);
    System.out.println(myLetter);
    System.out.println(myBool);
    System.out.println(myText);
  }
}

挪威w3schools.com練習Java code截圖