List.toArray
convert List to array
Calling Sequence
Parameters
Description
Examples
Object[] toArray()
T[] toArray( T[] a )
a
-
array
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.
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)
See Also
ExternalCalling/Java/MapleException
OpenMaple
OpenMaple/Java/Algebraic
OpenMaple/Java/API
OpenMaple/Java/List
OpenMaple/Java/List/contains
OpenMaple/Java/List/containsAll
OpenMaple/Java/List/iterator
OpenMaple/Java/List/select
Download Help Document