三种字符数组合并的方法

来源:互联网 发布:域名注册通 吾爱破解 编辑:程序博客网 时间:2024/05/22 14:48
三种字符数组合并的方法
public static String[] getOneArray() {
  String[] a = { "0""1""2" };
  String[] b = { "0""1""2" };
  String[] c = new String[a.length + b.length];
  for (int j = 0; j < a.length; ++j) {
   c[j] = a[j];
  }
  for (int j = 0; j < b.length; ++j) {
   c[a.length + j] = b[j];
  }
  return c;
 }
 public static Object[] getTwoArray() {
  String[] a = { "0""1""2" };
  String[] b = { "0""1""2" };
  List aL = Arrays.asList(a);
  List bL = Arrays.asList(b);
  List resultList = new ArrayList();
  resultList.addAll(aL);
  resultList.addAll(bL);
  Object[] result = resultList.toArray();
  return result;
 }
 public static String[] getThreeArray() {
  String[] a = { "0""1""2""3" };
  String[] b = { "4""5""6""7""8" };
  String[] c = new String[a.length + b.length];
  System.arraycopy(a, 0, c, 0, a.length);
  System.arraycopy(b, 0, c, a.length, b.length);
  return c;
 }
0 0
原创粉丝点击