從codes學java tiger之varargs

          Posted on 2006-06-26 20:25 BlueO2 閱讀(387) 評論(0)  編輯  收藏 所屬分類: JAVA foundation
          public ? class ?Artist? {
          ????
          ????String[]?others;
          ????
          /** ?Creates?a?new?instance?of?Artist? */
          ????
          public ?Artist()? {
          ????}

          ????
          public ?Artist(String?name,String??others) {
          ????????
          for (String?other?:?others) {
          ????????????System.out.println(other);
          ????????}

          ????????
          this .others? = ?others;
          ????}

          ????
          public ? void ?wildestMethod(Object??objs) {
          ????
          // this?method?will?accept?any?arguments
          ????}

          ????
          public ? static ? void ?main(String[]?args) {
          ????????Artist?artist?
          = ? new ?Artist( " You " ,? " 1 " ,? " 2 " );
          ????????artist.wildestMethod(
          1 ,? 3.5 ,? " AA " ,? new ?Artist());
          ????}

          ????
          }

          posts - 29, comments - 3, trackbacks - 0, articles - 0

          Copyright © BlueO2

          主站蜘蛛池模板: 乐山市| 阳西县| 中牟县| 兰西县| 申扎县| 沧源| 石家庄市| 从化市| 始兴县| 清水县| 九台市| 阳原县| 平乡县| 平塘县| 四会市| 泰宁县| 乌拉特前旗| 巴塘县| 长葛市| 五寨县| 灵宝市| 永德县| 吐鲁番市| 邛崃市| 赣州市| 吉首市| 庆城县| 定襄县| 平度市| 宜良县| 盐池县| 介休市| 东乌珠穆沁旗| 和平县| 枣阳市| 沙坪坝区| 长武县| 康定县| 江永县| 南召县| 正定县|