本帖最后由 masai158 于 2014-8-18 22:46 编辑
- import java.lang.reflect.Method;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Iterator;
- import java.util.List;
- import java.util.concurrent.Executors;.
- public class Demodsa3fsd
- {
- public static void main(Stng[] args)
- {
- List<String> al= new ArrayList<String>();
- al.add("aaa");
- al.add("bbb");
- al.add("ccc");
- al.add("ddd");
- System.out.println(al);
- fill(al,1,3,"kkkk");
- System.out.println(al);
-
- }
-
-
- public static void fill(List<String> list, int from, int to,String str)
- {
- List startList = null;
- List endList = null;
- try
- {
- startList = list.subList(0, from);
- endList = list.subList(from, to);
- }
- catch(IndexOutOfBoundsException e)
- {
- throw new RuntimeException("修改脚本越界,最小 0,最大" + list.size() );
- }
-
- Collections.fill(endList, str);
-
- List newList = new ArrayList();
- newList.addAll(startList);
- newList.addAll(from, endList);
- }
- }
复制代码 |
|