Name |
splice()插入数组 |
||||||
Examples |
String[] a = { “OH”, “NY”, “CA” }; a = splice(a, “KY”, 1); // Splice one value into an array println(a); // Prints the following array contents to the console: // [0] “OH” // [1] “KY” // [2] “NY” // [3] “CA”
println(); // Prints a blank line
String[] b = { “VA”, “CO”, “IL” }; a = splice(a, b, 2); // Splice one array of values into another println(a); // Prints the following array contents to the console: // [0] “OH” // [1] “KY” // [2] “VA” // [3] “CO” // [4] “IL” // [5] “NY” // [6] “CA” |
||||||
Description |
Inserts a value or an array of values into an existing array. The first two parameters must be arrays of the same datatype. The first parameter specifies the intial array to be modified, and the second parameter defines the data to be inserted. The third parameter is an index value which specifies the array position from which to insert data. (Remember that array index numbering starts at zero, so the first position is 0, the second position is 1, and so on.) When splicing an array of objects, the data returned from the function must be cast to the object array’s data type. For example: SomeClass[] items = (SomeClass[]) splice(array1, array2, index) 将值或值数组插入到现有数组中。前两个参数必须是同一数据类型的数组。第一个参数指定要修改的初始数组, 第二个参数定义要插入的数据。第三个参数是一个索引值, 它指定用于插入数据的数组位置。(请记住, 数组索引编号从零开始, 因此第一个位置为 0, 第二个位置为 1, 等等。
在拼接对象数组时, 必须将从该函数返回的数据转换为对象数组的数据类型。例如: SomeClass [] 项 = (SomeClass []) 拼接 (array1、array2、索引) |
||||||
Syntax |
splice(list, value, index) |
||||||
Parameters |
|
||||||
Returns |
boolean[], byte[], char[], int[], float[], String[], or Object |
||||||
Related |
concat() |
- 本文固定链接: http://iprocessing.cn/2017/07/21/1031/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表