toCollection
val numbers = arrayOf(1, 2, 3, 4, 5)
val list = mutableListOf<Int>()
// 将数组元素添加到 LinkedList 中
numbers.toCollection(list)
// 输出:List: [1, 2, 3, 4, 5]
_console.log("List: ", list)
def numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Integer"), 1, 2, 3, 4, 5))
def list = $objectWrappers.wrap($iterables.mutableListOf())
// 将数组元素添加到 LinkedList 中
numbers.toCollection(list)
// 输出:List: [1, 2, 3, 4, 5]
$console.log("List: ", list)
let numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Integer"), 1, 2, 3, 4, 5))
let list = $objectWrappers.wrap($iterables.mutableListOf())
// 将数组元素添加到 LinkedList 中
numbers.toCollection(list)
// 输出:List: [1, 2, 3, 4, 5]
$console.log("List: ", list)
local numbers = _objectWrappers:wrap(_arrays:arrayOf(_plugins:loadClass("java.lang.Integer"), 1, 2, 3, 4, 5))
local list = _objectWrappers:wrap(_iterables:mutableListOf())
-- 将数组元素添加到 LinkedList 中
numbers:toCollection(list)
-- 输出:List: [1, 2, 3, 4, 5]
_console:log("List: ", list)
<?php
$numbers = $objectWrappers->wrap($arrays->arrayOf($plugins->loadClass("java.lang.Long"), 1, 2, 3, 4, 5));
$list = $objectWrappers->wrap($iterables->mutableListOf());
// 将数组元素添加到 LinkedList 中
$numbers->toCollection($list);
// 输出:List: [1, 2, 3, 4, 5]
$console->log("List: ", $list);
numbers = _objectWrappers.wrap(_arrays.arrayOf(_plugins.loadClass("java.lang.Long"), 1, 2, 3, 4, 5))
list = _objectWrappers.wrap(_iterables.mutableListOf())
# 将数组元素添加到 LinkedList 中
numbers.toCollection(list)
# 输出:List: [1, 2, 3, 4, 5]
_console.log("List: ", list)
# encoding: utf-8
numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Long"), 1, 2, 3, 4, 5))
list = $objectWrappers.wrap($iterables.mutableListOf())
# 将数组元素添加到 LinkedList 中
numbers.toCollection(list)
# 输出:List: [1, 2, 3, 4, 5]
$console.log("List: ", list)
Last modified: 29 April 2025