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. scanf()与gets()的区别

    scanf()与gets()的区别 1.scanf()可以同时接受多个字符串,而gets()一次只能接受一个字符串. #include<stdio.h>int main(){ char s ...

  2. asp.net 操作word 权限

    1.先安装office 2.在“DCOM配置”中,为IIS账号配置操作Word(其他Office对象也一样)的权限: 开始>运行>输入  dcomcnfg  >确定 具体操作:“组件 ...

  3. Windows下Java JDK8配置环境变量

    JDK最新版已经出到了jdk8u60,下载安装完成后,还需要配置环境变量,下面小编就给大家分享下jdk 8.0的环境变量配置教程,希望大家喜欢. jdk8.0环境变量配置教程 右键选择 计算机→属性→ ...

  4. Python源码分析之dis

    一.简单例子 def add(a, b): return a + b add_nums.py import foo a = [1, 'python'] a = 'a string' def func( ...

  5. 集合(List、Set、Map)

    List,Set是继承自Collection接口,Map不是 public interface List<E> extends Collection<E> { public i ...

  6. PHP 中的文本截取分析之效率

    PHP 中的文本截取分析之效率 在使用 ThinkPHP 或 Laravel 时都会有用到文本截取的帮助函数. 分别是 msubstr (ThinkPHP 3,ThinkPHP 5 没找到) mb_s ...

  7. git推送报错: No path specified. See 'man git-pull' for valid url syntax或does not appear to be a git repository以及remote: error: insufficient permission for adding an object to repository databa

    本地(windows)代码想推送到linux自己搭建的git服务端,第一步是建立本地与服务端的关联,第二步是本地推送到服务端. 第一步需要看你的本地工程是否从git上clone来的,如果是clone来 ...

  8. 【android】SDK在线升级

    1.修改本地hosts文件 hosts文件位置:C:\Windows\System32\drivers\etc\hosts 在底部添加:203.208.46.146 dl-ssl.google.com ...

  9. java wab----遇到经常用到集合list/map/

    List与Vector的区别: vector适用:对象数量变化少,简单对象,随机访问元素频繁 list适用:对象数量变化大,对象复杂,插入和删除频] List首先是链表,它的元素不是连续的.vecto ...

  10. mysql-5null值处理

    值为null遇到的问题: 1.使用select对数据进行处理时,如果有格值为null,该命令会无法正常工作.如示例一 2.使用where限定条件时,null值不能处理.如示例二 -- 新建一张表,并填 ...