Jcat
          寵辱不驚,閑看庭前花開花落~~
          posts - 173,comments - 67,trackbacks - 0
          Experience
          To know how dose List.remove(Object) work, I do many test sample. But I still feel not very realizing. Finally, I?took a look at?souce code, and then I knew everything!
          public?boolean?remove(Object?o)?{
          ????
          if?(o?==?null)?{
          ????????????
          for?(int?index?=?0;?index?<?size;?index++)
          ????????
          if?(elementData[index]?==?null)?{
          ????????????fastRemove(index);
          ????????????
          return?true;
          ????????}

          ????}
          ?else?{
          ????????
          for?(int?index?=?0;?index?<?size;?index++)
          ????????
          if?(o.equals(elementData[index]))?{
          ????????????fastRemove(index);
          ????????????
          return?true;
          ????????}

          ????????}

          ????
          return?false;
          ????}
          1. List store very object's reference but object's own.
          2. remove(Object) will remove the first reference in List which refer to?the object
          3. If you want to change an object to a new index: back up it--> remove it--> re-add it

          Experience
          I create a class to handle something annotated by Annotations. But it doesn't work. I found out it is returned false by Class.getMethod().isAnnotationPresent(Todo.class). Finally, I got the reason by reading source code.
          public?enum?RetentionPolicy?{
          ????
          /**
          ?????*?Annotations?are?to?be?discarded?by?the?compiler.
          ?????
          */
          ????SOURCE,

          ????
          /**
          ?????*?Annotations?are?to?be?recorded?in?the?class?file?by?the?compiler
          ?????*?but?need?not?be?retained?by?the?VM?at?run?time.??This?is?the?default
          ?????*?behavior.
          ?????
          */
          ????CLASS,

          ????
          /**
          ?????*?Annotations?are?to?be?recorded?in?the?class?file?by?the?compiler?and
          ?????*?retained?by?the?VM?at?run?time,?so?they?may?be?read?reflectively.
          ?????*
          ?????*?
          @see?java.lang.reflect.AnnotatedElement
          ?????
          */
          ????RUNTIME
          }

          posted on 2006-08-03 18:43 Jcat 閱讀(343) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 政和县| 花莲市| 梓潼县| 天镇县| 永靖县| 中牟县| 平安县| 廊坊市| 平度市| 全州县| 邵东县| 彭山县| 潼南县| 平舆县| 泸溪县| 泗阳县| 灵石县| 雅安市| 饶河县| 山阴县| 敦煌市| 丘北县| 宿迁市| 甘泉县| 翁牛特旗| 深州市| 海丰县| 阿拉尔市| 济宁市| 西和县| 道真| 仙桃市| 陇西县| 乐平市| 栖霞市| 光泽县| 铁岭市| 保定市| 曲水县| 天全县| 余江县|