從codes學java tiger之varargs

          Posted on 2006-06-26 20:25 BlueO2 閱讀(388) 評論(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

          主站蜘蛛池模板: 浏阳市| 岳阳市| 象州县| 喜德县| 武强县| 广州市| 密云县| 抚远县| 永年县| 巩留县| 湘阴县| 铜鼓县| 曲沃县| 天柱县| 松阳县| 东阳市| 石棉县| 石狮市| 托里县| 句容市| 宜宾县| 大同市| 舟山市| 雅安市| 中宁县| 嘉兴市| 绥宁县| 北流市| 元氏县| 壶关县| 高尔夫| 台东市| 肃北| 五家渠市| 余江县| 昌黎县| 米脂县| 偃师市| 北京市| 甘孜县| 望奎县|