首页 > 文档 > subset()子集
2017
08-01

subset()子集

Name

subset()子集

   

Examples

String[] sa1 = { “OH”, “NY”, “CA”, “VA”, “CO”, “IL” };

String[] sa2 = subset(sa1, 1);

println(sa2);

// Prints the following array contents to the console:

// [0] “NY”

// [1] “CA”

// [2] “VA”

// [3] “CO”

// [4] “IL”

println();

String[] sa3 = subset(sa1, 2, 3);

println(sa3);

// Prints the following array contents to the console:

// [0] “CA”

// [1] “VA”

// [2] “CO”

Description

Extracts an array of elements from an existing array. The list parameter defines the array from which the elements will be copied, and the start and count parameters specify which elements to extract. If no count is given, elements will be extracted from the start to the end of the array. When specifying the start, remember that the first array element is 0. This function does not change the source array.

When using 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[]) subset(originalArray, 0, 4)

从现有数组中提取元素数组。list 参数定义了将从中复制元素的数组, 开始和计数参数指定要提取的元素。如果没有给出计数, 将从开始到数组的末尾提取元素。指定开始时, 请记住第一个数组元素是0。此函数不更改源数组。

 

当使用对象数组时, 从函数返回的数据必须转换为对象数组的数据类型。例如: SomeClass [] = (SomeClass []) 子集 (originalArray, 0, 4)

Syntax

subset(list, start)

subset(list, start, count)

Parameters

list

Object, String[], float[], int[], char[], byte[], or boolean[]: array to extract from

要从中提取的数组

start

int: position to begin开始的位置

count

int: number of values to extract

要提取的个数

Returns

boolean[], byte[], char[], int[], float[], String[], or Object

Related

splice()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。