Groovy Lists plus()方法
2018-12-29 15:44 更新
创建由原始元素和集合中指定的元素组成的新列表。
句法
List plus(Collection collection)
参数
集合 - 要添加到列表的值的集合。
返回值
新的值列表。
例子
下面是一个使用这个方法的例子 -
class Example {
static void main(String[] args) {
def lst = [11, 12, 13, 14];
def newlst = [];
newlst = lst.plus([15,16]);
println(newlst);
}
}
当我们运行上面的程序,我们将得到以下结果 -
[11, 12, 13, 14, 15, 16]
以上内容是否对您有帮助:

免费 AI IDE


更多建议: