JavaArray class
Native Java Arrays
Test scripts can create native Java arrays, and insert and retrieve objects stored in the arrays. For examples of use, see Creating and Using JavaArrays.
Array JavaArray(size)
Array JavaArray(size, nameOfType)
This is a constructor function for creating native Java arrays. The size
specifies how many objects it may contain (indexed from 0, so the last valid index is size
- 1
). If the optional nameOfType
string is omitted, the function will return an array of type java.lang.Object[size]
; otherwise the array will be of type nameOfType[size]
.
The nameOfType
is a string that can specify a non-object type such as "int"
, or an object type such as "java.lang.String"
.
JavaArray
s have two functions and one property.
Object JavaArray.at(index)
This function returns the object at position index
in the array. If the index
is out of bounds a catchable exception is raised.
int javaArray.length
This read-only property holds the number of positions in the array. The first item is at position 0 and the last item is at position javaArray.length - 1
.
Object JavaArray.set(index, object)
This function sets the item at position index
in the array to the given object
. If the index
is out of bounds or if the object
is of an invalid type (e.g., a string when the JavaArray holds integers), a catchable exception is raised.
© 2024 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners.