toArray - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

List.toArray

convert List to array

 Calling Sequence Object[] toArray() T[] toArray( T[] a )

Parameters

 a - array

Description

 • The toArray function returns an array corresponding to the elements of the List.
 • When invoked with no arguments, toArray returns an array of type Object populated with elements of the List.
 • When invoked with an array argument, toArray returns an array populated with the elements of the List. The runtime type T of this array matches that of the input array a.

Examples

 import com.maplesoft.openmaple.*; import com.maplesoft.externalcall.MapleException; class Example { public static void main( String notused[] ) throws MapleException { String[] mapleArgs = { "java" }; Engine engine = new Engine( mapleArgs, new EngineCallBacksDefault(), null, null ); List s = (List)engine.evaluate( "[2,5,8,exp(2*x)];" ); Object[] arr = s.toArray(); for (int i = 0; i < arr.length, i++) System.out.println( "Element " + i + ": " + arr[i] ); } Algebraic[] algArray_in = new Algebraic[1]; Algebraic[] algArray_out = s.toArray( algArray_in ); } }

Executing this code produces the following output:

 Element 0: 2 Element 1: 5 Element 2: 8 Element 3: exp(2*x)