Choose where you’d like to start

subList()

Overview

The subList() function takes listVariable , start_index and end_index as arguments. It returns the list containing elements between the specified indices (including the start_index and excluding the end_index).

Note: Index starts from 0.

Return Type

  • List

Syntax

<variable> = <listVariable>.subList( <start_index>, <end_index> );
ParameterDescriptionData type
<variable>Variable which will contain the returned list.LIST
<listVariable>The list from which the elements will be returned.LIST
<start_index>

The index starting from which the elements will be returned from the list.

If a negative value is specified, an error will be encountered during runtime.

NUMBER
<end_index>

The index till which the elements will be returned from the string. If omitted, the rest of the list will be returned.

The end_index should not exceed the count of elements in the list. If it does, an error will be encountered during runtime.

NUMBER

Examples

listVar= {1, 2, 3, 4};
newListVar= listVar.subList(0, 3);           // returns {1, 2, 3}

Get Started Now

Execute