gembin

          OSGi, Eclipse Equinox, ECF, Virgo, Gemini, Apache Felix, Karaf, Aires, Camel, Eclipse RCP

          HBase, Hadoop, ZooKeeper, Cassandra

          Flex4, AS3, Swiz framework, GraniteDS, BlazeDS etc.

          There is nothing that software can't fix. Unfortunately, there is also nothing that software can't completely fuck up. That gap is called talent.

          About Me

           

          Why not throwing an ArrayIndexOutOfBoundsException?

          Let's take a look at the following code:

          public Class Program{
          public static void main(String[] args){
          int i = 0;
          int[] a = {1,2};
          a[i] = i = 2;
          System.out.println(i + " " + a[0]+ " "+a[1]);
          }
          }

          What is the output from the above code?

          The output is:

          2 2 2

          You may raise some questions: "When does i get a value 2?", "Why doesn't it use the same value (i=2) for a[i] (which should actually give an ArrayOutOfBoundsException Exception)?", and so on.

          The reason no ArrayIndexOutOfBoundsException is thrown is because each of the operands is evaluated from left to right. Basically the array reference is evaluated first then the rest of the expression is done according to the rules in the posted on 2010-07-08 14:25 gembin 閱讀(447) 評論(0)  編輯  收藏 所屬分類: JavaSE

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(6)

          隨筆分類(440)

          隨筆檔案(378)

          文章檔案(6)

          新聞檔案(1)

          相冊

          收藏夾(9)

          Adobe

          Android

          AS3

          Blog-Links

          Build

          Design Pattern

          Eclipse

          Favorite Links

          Flickr

          Game Dev

          HBase

          Identity Management

          IT resources

          JEE

          Language

          OpenID

          OSGi

          SOA

          Version Control

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          free counters
          主站蜘蛛池模板: 双城市| 南宁市| 余干县| 开原市| 钦州市| 博白县| 黎川县| 石棉县| 十堰市| 库伦旗| 革吉县| 凉山| 文水县| 略阳县| 海原县| 右玉县| 西乌珠穆沁旗| 德化县| 巨野县| 林周县| 黔江区| 湛江市| 平潭县| 蚌埠市| 长兴县| 彰武县| 藁城市| 崇左市| 兴城市| 达州市| 万载县| 高平市| 正阳县| 克拉玛依市| 同德县| 金山区| 鄢陵县| 体育| 额尔古纳市| 大姚县| 中卫市|