codecamp

Groovy pop()方法

从此列表中删除最后一个项目。

句法

Object pop() 

参数

没有

返回值

从列表中弹出的值。

例子

下面是一个使用这个方法的例子 -

class Example { 
   static void main(String[] args) { 
      def lst = [11, 12, 13, 14]; 

      println(lst.pop()); 
      println(lst); 
   } 
}

当我们运行上面的程序,我们将得到以下结果 -

14 
[11, 12, 13]
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定