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

          導航

          統計

          常用鏈接

          留言簿(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
          主站蜘蛛池模板: 江永县| 玉龙| 华宁县| 昔阳县| 乐业县| 积石山| 梨树县| 肇州县| 凌源市| 开化县| 洪泽县| 黑山县| 保德县| 乌苏市| 维西| 温宿县| 井研县| 什邡市| 乌兰浩特市| 兴仁县| 遂川县| 黔东| 商城县| 泰兴市| 中卫市| 松滋市| 安塞县| 洞头县| 泰安市| 永寿县| 泰州市| 安徽省| 浠水县| 江油市| 大足县| 长寿区| 松潘县| 毕节市| 库尔勒市| 南宫市| 新安县|