從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

          主站蜘蛛池模板: 伽师县| 连州市| 蚌埠市| 赤峰市| 额尔古纳市| 夹江县| 辽源市| 三都| 余姚市| 墨竹工卡县| 焦作市| 松潘县| 荔浦县| 思南县| 塔城市| 洛南县| 马关县| 南木林县| 体育| 那曲县| 曲靖市| 铜梁县| 临安市| 泽普县| 安阳市| 固镇县| 留坝县| 大荔县| 平南县| 呼伦贝尔市| 友谊县| 西乌珠穆沁旗| 河西区| 独山县| 涞水县| 铜鼓县| 泰兴市| 普安县| 会宁县| 苏尼特右旗| 商河县|