博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Array and ArrayList
阅读量:5327 次
发布时间:2019-06-14

本文共 1270 字,大约阅读时间需要 4 分钟。

Array:

def x = new String[5]x[0] = "India"x[1] = "USA"x[2] = "Korea"x[3] = "Japan"x[4] = "China"log.info "Size of list is " + x.size()log.info "The first item in list is : "+x[0]for(String item:x){	log.info item}

 Result :

Tue Jun 16 14:50:08 CST 2015:INFO:Size of list is 5

Tue Jun 16 14:50:08 CST 2015:INFO:The first item in list is : India
Tue Jun 16 14:50:08 CST 2015:INFO:India
Tue Jun 16 14:50:08 CST 2015:INFO:USA
Tue Jun 16 14:50:08 CST 2015:INFO:Korea
Tue Jun 16 14:50:08 CST 2015:INFO:Japan
Tue Jun 16 14:50:08 CST 2015:INFO:China

ArrayList :

ArrayList list = new ArrayList();list.add("India")list.add("USA")list.add("UK")list.add("China")log.info "Size of list is "+list.size()list.add("Korea")log.info "Size of list is "+list.size()log.info "The first item in list is : " + list.get(0)for(String item:list){	log.info item}

 

 Result:

Tue Jun 16 14:57:43 CST 2015:INFO:Size of list is 4

Tue Jun 16 14:57:43 CST 2015:INFO:Size of list is 5
Tue Jun 16 14:57:43 CST 2015:INFO:The first item in list is : India
Tue Jun 16 14:57:43 CST 2015:INFO:India
Tue Jun 16 14:57:43 CST 2015:INFO:USA
Tue Jun 16 14:57:43 CST 2015:INFO:UK
Tue Jun 16 14:57:43 CST 2015:INFO:China
Tue Jun 16 14:57:43 CST 2015:INFO:Korea

转载于:https://www.cnblogs.com/MasterMonkInTemple/p/4580805.html

你可能感兴趣的文章
[Windows Server]安装系统显示“缺少计算机所需的介质驱动程序”解决方案
查看>>
nginx日志切割脚本
查看>>
[容斥][dp][快速幂] Jzoj P5862 孤独
查看>>
Reflect反编译C#程序
查看>>
DSAPI 字符串和文件转Md5字符串
查看>>
Lucene 学习之二:数值类型的索引和范围查询分析
查看>>
软件开发工作模型
查看>>
20165301 2017-2018-2 《Java程序设计》第九周学习总结
查看>>
tomcat启动时出现了Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
查看>>
基础测试jmeter5.0+badboy(从小白到入门)
查看>>
Java基础之字符串匹配大全
查看>>
SGA和PGA的分配原则及更改大小
查看>>
面向对象
查看>>
lintcode83- Single Number II- midium
查看>>
HTML5学习笔记简明版(2):新元素之section,article,aside
查看>>
移动端 响应式、自适应、适配 实现方法分析(和其他基础知识拓展)
查看>>
PHP之Trait详解
查看>>
Netty学习(三)高性能之ByteBuf源码解析(篇幅较长)
查看>>
selenium-窗口切换
查看>>
selenium-滚动
查看>>