Java標識符 關鍵字

標識符: 主要是給類、變量、方法起名字

命名規則:


 1. 首字母必須是下劃線、字母、$ 
 2. 其餘部分可以是字母、數字、下劃線、$ 
 3. Java大小寫敏感,且長度無限制,適中就好
 4. 見名知意,建議使用英文
 5. 不可以使用Java關鍵字


關鍵字:

abstract        boolean      break       byte        case catch     char(character) class   const   continue    defaultdo double    else    extends     final       finally         float       for     goto        if

 implements import  instanceof  int     interface   long        native  new null
        package private protected   public      return      short 
        static          strictfp    super       switch      synchronizedthis        throw           throws      transient   try         void
        volatile    while       

<h1>代碼示例:<h1/>
-----

public static oid main(String[] args){
//錯誤的標識符
//int 1a = 10;
//int #a = 10;

int _a = 10;
int $a = 10;
int a1 = 10;
int aa = 10;

int age =20;
int width = 50;
int height = 180;
String name = "張三";

//標識符雖然漢字可以,但是不要去使用
int ¥a =10;
int 你好=10;
}
}

標識符的類型:
Java是一種強類型的語言,標識符在定義的時候必須聲明它的類型

十進制轉換二進制
        讓數字對2取餘(0/1)    然後商對2繼續取餘,一直取道1,然後將取道的餘數倒過來
二進制轉換十進制
發佈了29 篇原創文章 · 獲贊 3 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章