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

[Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Array and ArrayList的更多相关文章

  1. [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Exception Handling in groovy

    def x = new String[3] x[0] = "A" x[1] = "B" x[2] = "C" log.info"X ...

  2. [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] HashSet and Hashtable

    Hashset: HashSet set = new HashSet() set.add("India") set.add("USA") set.add(&qu ...

  3. Common tasks that you can perform with the Groovy Script test step

    https://support.smartbear.com/readyapi/docs/soapui/steps/groovy.html Get test case object To obtain ...

  4. [Training Video - 2] [Groovy Introduction]

    Building test suites, Test cases and Test steps in SOAP UI Levels : test step level test case level ...

  5. [Training Video - 4] [Groovy] Optional parameter in groovy

    Employee.log=log Employee e1 = new Employee() log.info e1.add(1,2,3,4) // optional parameters in gro ...

  6. [Training Video - 4] [Groovy] String Functions

    def x="I like to read books before bed" def temp = x.split(" ") log.info "S ...

  7. [Training Video - 4] [Groovy] Object equality and variable equality check

    def x=2 def y=3 if(x == y){ log.info "equal" }else{ log.info "not equal" // prin ...

  8. [Training Video - 4] [Groovy] Initializing log inside class with constructor

    TestService s = new TestService(log,context,testRunner) s.xyz() class TestService{ def log def conte ...

  9. [Training Video - 4] [Groovy] Constructors in groovy, this keyword

    Bank.log = log Bank b1 = new Bank() b1.name = "BOA" b1.minbalance = 100 b1.city="Lond ...

随机推荐

  1. 谷歌浏览器怎么调试js 谷歌浏览器调试javascript教程

    谷歌浏览器是一款由谷歌公司开发的浏览器.谷歌浏览器是一款基于其他开源软件所撰写的.下面小编为大家分享一篇谷歌浏览器调试javascript的教程,希望帮助大家 首先我们打开开发者工具,你可以直接在页面 ...

  2. opencv之批量转换灰度图并保存

    当图片名字有数字规律时,批量处理方式. ①srcImage 图片名字有规律 ②将srcImage文件下的图片,转换为灰度图并保存入grayImage文件夹. ③ #include <iostre ...

  3. LG4717 【模板】快速沃尔什变换

    题意 题目描述 给定长度为\(2^n\)两个序列\(A,B\),设\(C_i=\sum_{j\oplus k}A_jB_k\)分别当\(\oplus\)是or,and,xor时求出C 输入输出格式 输 ...

  4. PAT 1016 部分A+B C语言

    1016. 部分A+B (15) 正整数A的“DA(为1位整数)部分”定义为由A中所有DA组成的新整数PA.例如:给定A = 3862767,DA = 6,则A的“6部分”PA是66,因为A中有2个6 ...

  5. Python中定时任务框架APScheduler

    前言 大家应该都知道在编程语言中,定时任务是常用的一种调度形式,在Python中也涌现了非常多的调度模块,本文将简要介绍APScheduler的基本使用方法. 一.APScheduler介绍 APSc ...

  6. PHP安全性漫谈

    最近刚做完两个PHP的网站项目,客户虽然没有安全性的相关需求,但是自己不能放过对自己的要求,何况对以后做电子商务的项目相当有帮助,呵呵,早准备早超生,经过查看PHP 帮助和相关资料~~~~       ...

  7. Panabit Live CD使用说明

    为了方便更多的用户实际使用Panabit,省去安装FreeBSD和Panabit等步骤,自2007年9月,即Panabit V7.09起,Panabit网站发布Panabit标准版安装包时,同步发布相 ...

  8. myeclipse修改内存大小不足

    工具中修改设置Default VM Arguments   1 打开MyEclipse,如下图所示 2 打开Windows-> Preferences 3 然后选择右侧菜单的Java->I ...

  9. unity的sprite添加点击事件

    直接说方法 添加一个2dxxx的碰撞器 添加一个OnMouseDown的回调函数,这个函数看script reference就可以

  10. 设置cassandra用户名和密码

    参考http://zhaoyanblog.com/archives/307.html 修改cassandra.yaml配置文件 把默认的 authenticator: AllowAllAuthenti ...