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. 2016-the brave never die

    2016年最后一天工作日了,由于这段时间一直忙于春节项目没时间写点关于2016年的总结,回忆一下,2016年其实还有很多事情没做好,究其原因,感觉是因为对于2016年没有做任何的规划和计划,就凭着一股 ...

  2. 黄聪:自定义WordPress顶部管理工具条的技巧(转)

    使用WordPress开发网站项目,很多时候都需要对进行后台定制,今天倡萌主要分享下自定义顶部管理工具条的使用技巧. 注:如无特殊说明,请将下面的代码添加到主题的 functions.php  或者插 ...

  3. 谈谈对zynq的浅显理解

    zynq并不能说是一个嵌入arm核的FPGA.从它的启动过程就可以发现,绝对是arm主导的,所以称它为以高性能FPGA为外设的双核arm或许更为合适.以下是优势: 第一个:开发环境的大集成.从hls到 ...

  4. send函数和recv函数

    1.send 函数 int send( SOCKET s, const char FAR *buf, int len, int flags );   不论是客户还是服务器应用程序都用send函数来向T ...

  5. librtmp接收flv流中提取h264码流:根据多个资料汇总

    rtmpdump可以下载rtmp流并保存成flv文件.如果要对流中的音频或视频单独处理,需要根据flv协议分别提取.简单修改rtmpdump代码,增加相应功能.1 提取音频:rtmpdump程序在Do ...

  6. java6枚举类型

    java.lang.Enum > 使用enum定义. 类如: public class EnumDemo { enum Edge { TOP, BOTTOM, LEFT, RIGHT//定义了一 ...

  7. mysql 使用 informatin_schema tables 创建 shell commands

    SELECT CONCAT("mysqldump -uroot -p ", TABLE_SCHEMA, " ", TABLE_NAME, " > ...

  8. Linux tar命令高级用法——备份数据

    Linux tar命令高级用法——备份数据 2015-12-31 Linux学习 Linux上有功能强大的tar命令,tar最初是为了制作磁带备份(tape archive)而设计的,它的作用是把文件 ...

  9. zabbix 报警方式之 邮件报警(4)

    一.为什么要自定义邮件脚本报警? 灵活,方便.可以自定义过滤信息. 下面是使用不同方式的邮件报警,一个是利用sendEmail程序来发送报警邮件,第二个是利用python脚本来发送邮件. 二.send ...

  10. cocos2dx切换播放的动画

    版本:cocos2dx 2.2.6 IDE: VS2012 语言:C++98 美术资源一共有两段动画的序列帧,一个是手绘马行走图,一个是分子人行走图. 程序要实现的目的就是在同一个位置,点击按钮可以实 ...