Module jballerina.java.arrays
ballerina/jballerina.java.arrays Ballerina library
1.4.0
Overview
This module provides APIs to create new Java array instances, get elements from arrays, set elements, etc.
Create a Java array instance
handle stringClass = check java:getClass("java.lang.String"); handle StrArray = arrays:newInstance(stringClass, 4);
Get an element from a Java array
handle firstWord = arrays:get(words, 0);
Replace an element in a Java array
arrays:set(strArray, 0, java:fromString("Ballerina"));
Get Java array length
int length = arrays:getLength(array);
Get a Ballerina array from a Java array
int[] array = <int[]> check arrays:fromHandle(arrayHandle, "int");
Get a Java array from a Ballerina array
handle handleValue = check arrays:toHandle(bArray, "char");