数组复制 向数组添加字符串
来源:互联网 发布:mac怎么删除双系统 编辑:程序博客网 时间:2024/06/06 23:50
System.arraycopy()参数使用
* @param src the source array.
* @param srcPos starting position in the source array.
* @param dest the destination array.
* @param destPos starting position in the destination data.
* @param length the number of array elements to be copied.
/**
** 两个数组合并
**/
public static String[] concatenateStringArrays(String[] array1, String[] array2) {
if (ObjectUtils.isEmpty(array1)) {
return array2;
}
if (ObjectUtils.isEmpty(array2)) {
return array1;
}
String[] newArr = new String[array1.length + array2.length];
System.arraycopy(array1, 0, newArr, 0, array1.length);
System.arraycopy(array2, 0, newArr, array1.length, array2.length);
return newArr;
}
/** 向数组中添加元素
* Append the given {@code String} to the given {@code String} array,
* returning a new array consisting of the input array contents plus
* the given {@code String}.
* @param array the array to append to (can be {@code null})
* @param str the {@code String} to append
* @return the new array (never {@code null})
*/
public static String[] addStringToArray(String[] array, String str) {
if (ObjectUtils.isEmpty(array)) {
return new String[] {str};
}
String[] newArr = new String[array.length + 1];
System.arraycopy(array, 0, newArr, 0, array.length);
newArr[array.length] = str;
return newArr;
}
- 数组复制 向数组添加字符串
- java向字符串数组中动态添加字符串
- 数组中使用strcpy、memcpy复制字符串,末尾添加‘\0’
- iOS 向可变数组中添加数组
- 向json数组添加元素
- js向数组添加元素
- 字符串数组添加元素
- iOS 字符串 向数组转换
- C++ 复制字符串/字符数组
- 字符串数组的复制(不仅仅字符串)
- 如何给数组添加字符串
- 向二维数组中添加元素
- 向数组开始添加元素array_unshift
- 向数组中循环添加内容
- 向数组中循环添加内容
- js向数组和map添加元素
- 定时向数组前面添加一个随机数
- 向可变数组中添加元素崩溃。。。
- 健忘者系列-MVC图片上传(二)
- 重新学习《C++Primer5》第12章-动态内存
- Nginx的SSL配置优化
- Android 中的 Service 全面总结
- 十五. 第一个shell script 脚本程序
- 数组复制 向数组添加字符串
- OpenCV HOG+SVM行人检测:从训练到检测
- 关系型数据库与Key-value型数据库Mongodb模式设计对比
- RxJava详解
- 杂想2016/6/1
- 基类Activity、Fragment、Dialog以及LogUtils、CursorUtils的写法(方便开发)
- windows 7 下安装多个 apache服务
- 数组循环移位
- C3P0连接池的三种实现方式