Jafe Lee

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            49 隨筆 :: 0 文章 :: 24 評論 :: 0 Trackbacks
          1、Java運(yùn)算符優(yōu)先級:

          Operator Precedence

          Operators

          Associativity

          [] . () (method call)

          Left to right

          ! ~ ++ -- + (unary) (unary) () (cast) new

          Right to left

          * / %

          Left to right

          + -

          Left to right

          << >> >>>

          Left to right

          < <= > >= instanceof

          Left to right

          == !=

          Left to right

          &

          Left to right

          ^

          Left to right

          |

          Left to right

          &&

          Left to right

          ||

          Left to right

          ?:

          Right to left

          = += -= *= /= %= &= |= ^= <<= >>= >>>=

          Right to left


          注意:
          • && || ! 的操作數(shù)只能用于boolean 或 Boolean
          • &? | 的操作數(shù)既可以用于boolean(Boolean)或者整形(不僅僅是int型),但兩個操作數(shù)的類型必須一致
          • ~不能用于boolean(Boolean)型,但可以用于整形,大概是為了和 ! 區(qū)別開來吧
          • & | 沒有短路計(jì)算的
          2、
          Java Integer Types

          Type

          Storage Requirement

          Range (Inclusive)

          int

          4 bytes

          –2,147,483,648 to 2,147,483,647 (just over 2 billion)

          short

          2 bytes

          –32,768 to 32,767

          long

          8 bytes

          –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

          byte

          1 byte

          –128 to 127

          ????? char?? ?? ?? ?? ????????? ? 2 bytes? ?? ?? ?? ?? ?? ?? ?? ????? 0 to 65535

          3、

          Floating-Point Types

          Type

          Storage Requirement

          Range

          float

          4 bytes

          approximately ±3.40282347E+38F (6–7 significant decimal digits)

          double

          8 bytes

          approximately ±1.79769313486231570E+308 (15 significant decimal digits)


          4、final 實(shí)例域(final instance field):可以將實(shí)例域定義為final,構(gòu)建對象時(shí)必須初始化這樣得域,也就是說,必須確保在每一個構(gòu)造器執(zhí)行之后,這個域的值被設(shè)置。但是,靜態(tài)常量必須在聲明的同時(shí)也被初始化。

          5、for each 循環(huán):
          for (variable : collection) statment
          例如:for (int element : a)
          ??? ?? ?? System.out.println(element);
          該代碼片段打印數(shù)組a的每一個元素,一個元素占一行

          6、合法的Java標(biāo)識符:可以以下劃線、字母或美元符號$開頭,后面可以跟下劃線、數(shù)字、字母、美元符號。1.42以后的java標(biāo)識符也可以包含漢字,包括開頭。
          posted on 2007-05-21 16:30 Jafe Lee 閱讀(256) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 古交市| 平利县| 木兰县| 乃东县| 乐业县| 信阳市| 行唐县| 镇赉县| 深水埗区| 开封市| 苗栗县| 基隆市| 饶阳县| 繁峙县| 中超| 赫章县| 宁安市| 巴楚县| 宜城市| 旌德县| 河东区| 田阳县| 星子县| 天气| 南召县| 锡林郭勒盟| 永州市| 航空| 禹州市| 神池县| 合肥市| 衡东县| 奇台县| 兖州市| 虎林市| 洪泽县| 南城县| 都昌县| 通许县| 城口县| 鄯善县|