創(chuàng)建由原始元素和集合中指定的元素組成的新列表。
List plus(Collection collection)
集合 - 要添加到列表的值的集合。
新的值列表。
下面是一個(gè)使用這個(gè)方法的例子 -
class Example { static void main(String[] args) { def lst = [11, 12, 13, 14]; def newlst = []; newlst = lst.plus([15,16]); println(newlst); } }
當(dāng)我們運(yùn)行上面的程序,我們將得到以下結(jié)果 -
[11, 12, 13, 14, 15, 16]
更多建議: