- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

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)
Syntax |
    subset(list, start)
    subset(list, start, count)
Parameters |
list | Object, String[], double[], float[], long[], 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[], long[], float[], double[], String[], or Object
Related | splice()

Updated on January 1, 2021 03:38:07am EST
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.