從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

          主站蜘蛛池模板: 曲水县| 祁连县| 温州市| 南部县| 库尔勒市| 六盘水市| 阳江市| 庐江县| 桃园县| 山阴县| 宝兴县| 赤水市| 石屏县| 尼玛县| 淮安市| 嘉兴市| 福泉市| 洪湖市| 察雅县| 临武县| 延长县| 株洲县| 满洲里市| 盐山县| 富平县| 九江县| 务川| 蒙阴县| 乌鲁木齐市| 甘孜县| 辉南县| 禹州市| 神池县| 南乐县| 凤庆县| 彰化市| 新巴尔虎右旗| 榆林市| 玛曲县| 甘南县| 临猗县|