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 閱讀(430) 評論(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
          主站蜘蛛池模板: 环江| 福安市| 交城县| 玉树县| 丹寨县| 定结县| 满城县| 汶上县| 广元市| 卢湾区| 罗田县| 黄龙县| 乡城县| 且末县| 咸阳市| 遵义县| 耒阳市| 增城市| 星子县| 宁德市| 寻甸| 安西县| 台山市| 宣城市| 广宗县| 夹江县| 桦南县| 托克逊县| 都匀市| 巴彦淖尔市| 古丈县| 斗六市| 谷城县| 灵武市| 芮城县| 灵川县| 南丹县| 吉木萨尔县| 松溪县| 乐昌市| 上思县|