log.info "starting"
// we use class to create objects of a class
Planet p1 = new Planet()
Planet p2 = new Planet()
Planet p3 = new Planet() //Planet.name = "Pluto" illegal
Planet.shape = "Circle" p1.name = "earth"
//p1.shape = "circle" p2.name = "jupiter"
//p2.shape = "circle" p3.name = "mars"
//p3.shape = "circle" log.info p1.name+" "+p1.shape
log.info p2.name+" "+p2.shape
log.info p3.name+" "+p3.shape p1 = p2
log.info "*************************************"
log.info p1.name+" "+p1.shape
log.info p2.name+" "+p2.shape
log.info p3.name+" "+p3.shape p1.name = "pluto"
log.info "*************************************"
log.info p1.name+" "+p1.shape //pluto
log.info p2.name+" "+p2.shape //pluto
log.info p3.name+" "+p3.shape class Planet{
// variables and functions
def name // non static variable
def static shape // static variable
}

运行结果:

Tue Oct 06 16:27:27 CST 2015:INFO:starting
Tue Oct 06 16:27:27 CST 2015:INFO:earth Circle
Tue Oct 06 16:27:27 CST 2015:INFO:jupiter Circle
Tue Oct 06 16:27:27 CST 2015:INFO:mars Circle
Tue Oct 06 16:27:27 CST 2015:INFO:*************************************
Tue Oct 06 16:27:27 CST 2015:INFO:jupiter Circle
Tue Oct 06 16:27:27 CST 2015:INFO:jupiter Circle
Tue Oct 06 16:27:27 CST 2015:INFO:mars Circle
Tue Oct 06 16:27:27 CST 2015:INFO:*************************************
Tue Oct 06 16:27:27 CST 2015:INFO:pluto Circle
Tue Oct 06 16:27:27 CST 2015:INFO:pluto Circle
Tue Oct 06 16:27:27 CST 2015:INFO:mars Circle

[Training Video - 3] [Groovy in Detail] Non-static and Static variables, objects and object referances的更多相关文章

  1. [Training Video - 3] [Groovy in Detail] Non-static and Static functions, initializing log inside class

    log.info "starting" // we use class to create objects of a class Planet p1 = new Planet() ...

  2. [Training Video - 3] [Groovy in Detail] What is a groovy class ?

    log.info "starting" // we use class to create objects of a class Planet p1 = new Planet() ...

  3. [Training Video - 4] [Groovy] Function in detail

    Employee.log=log Employee e1 = new Employee() Employee e2 = new Employee() e1.name = "A" e ...

  4. [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 ...

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

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

  6. [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 ...

  7. [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 ...

  8. [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 ...

  9. [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Array and ArrayList

    Array: def x = new String[5] x[0] = "India" x[1] = "USA" x[2] = "Korea" ...

随机推荐

  1. 一段四表联查外加字符拼接的sql,留存备查

    select DISTINCT [P_ID],[P_CODE],[P_CODE_OLD],[P_NAME],[NATIVE_PLACE],[GENDER],[EDUCATION],[EMPLOY_DA ...

  2. Makefile编写 四 函数篇

    一.函数的调用语法 函数调用与变量一样,也是以“$”来标识的,其语法如下: $(<function> <arguments>) 或是 ${<function> &l ...

  3. k8s1.4.3安装实践记录(2)-k8s安装

    前面一篇已经安装好了ETCD.docker与flannel(k8s1.4.3安装实践记录(1)),现在可以开始安装k8s了 1.K8S 目前centos yum上的kubernetes还是1.2.0, ...

  4. centos6.9 x64安装http,php5.6,curl5.29,mysql最后安装zabbix3.4+zabbix客户端

    https://www.zabbix.com/documentation/3.4/zh/manual/installation/requirementshttps://www.zabbix.com/d ...

  5. centos开机提示CPU无法识别的问题

    centos版本和对应cpu兼容性,官方网址: https://access.redhat.com/support/policy/intel Red Hat Enterprise Linux Vers ...

  6. Linux中常用的查找文件的命令

    我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索.这些是从网上找到的资料(参考资料1),因为有时很长时间不会用到,当要用的时候经常弄混了,所以放到这里方便使用. w ...

  7. node.js 获取客户端信息

    结果:

  8. 自己个儿写的循环分配txt中的内容

    <?php header("Content-type:text/html;charset=utf8"); //当前日期 $now = time(); //作为程序是否执行的依 ...

  9. Linux 服务器--Iptables 端口转发

    日常Iptables 端口转发 需求:公司是局域网络,通过一个外网ip,进行互联网的访问.公司的云平台服务器在公网中,虚拟化平台中有一台内部服务器,用于公司某部门的使用,上面运行www 服务,ssh端 ...

  10. Python Twisted系列教程21: Twisted和Haskell

    作者:dave@http://krondo.com/twisted-and-haskell/  译者: Cheng Luo 你可以从”第一部分 Twist理论基础“开始阅读:也可以从”Twisted ...