從codes學java tiger之varargs

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

          主站蜘蛛池模板: 梁山县| 仪陇县| 文成县| 泽州县| 卢龙县| 大方县| 乌拉特后旗| 南投市| 遂昌县| 仪征市| 彭山县| 南木林县| 莱阳市| 周宁县| 珠海市| 巴东县| 西峡县| 勃利县| 江源县| 乌鲁木齐县| 奇台县| 深圳市| 江都市| 南木林县| 宾阳县| 伊金霍洛旗| 锡林郭勒盟| 都江堰市| 海门市| 伽师县| 菏泽市| 聂拉木县| 慈溪市| 沙洋县| 二手房| 杨浦区| 肥东县| 山东省| 宜春市| 沾化县| 修武县|