log.info "starting"
// we use class to create objects of a class
Planet p1 = new Planet()
Planet p2 = new Planet()
Planet p3 = new Planet() 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{
def name
def shape
}

运行结果:

Tue Oct 06 20:41:45 CST 2015:INFO:starting
Tue Oct 06 20:41:45 CST 2015:INFO:earth circle
Tue Oct 06 20:41:45 CST 2015:INFO:jupiter circle
Tue Oct 06 20:41:45 CST 2015:INFO:mars circle
Tue Oct 06 20:41:45 CST 2015:INFO:*************************************
Tue Oct 06 20:41:45 CST 2015:INFO:jupiter circle
Tue Oct 06 20:41:45 CST 2015:INFO:jupiter circle
Tue Oct 06 20:41:45 CST 2015:INFO:mars circle
Tue Oct 06 20:41:45 CST 2015:INFO:*************************************
Tue Oct 06 20:41:45 CST 2015:INFO:pluto circle
Tue Oct 06 20:41:45 CST 2015:INFO:pluto circle
Tue Oct 06 20:41:45 CST 2015:INFO:mars circle

[Training Video - 3] [Groovy in Detail] What is a groovy class ?的更多相关文章

  1. Groovy学习:第四章 Groovy特性深入

    作者:chszs 1. 断言 Java开发者常常使用JUnit或TestNG做单元测试,所以对断言是很清楚的.断言是用于验证假设的条件是否为真.在Groovy的断言中,如果假设的条件不为真,那么就会抛 ...

  2. Groovy学习:第三章 Groovy开发环境

    本章将继续深入Groovy语言,首先学习Groovy脚本,包括从命令行编译和运行Groovy脚本,Groovy Shell,和Groovy Console.你将学会使用Groovy语言来建立域对象.控 ...

  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 - 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() ...

  5. [Training Video - 3] [Groovy in Detail] Non-static and Static variables, objects and object referances

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

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

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

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

  8. [Training Video - 7] [Database connection] Various databases which are supported, Drivers for database connection, SQL Groovy API

    Various databases which are supported Drivers for database connection groovy.sql.Sql package SoapUI怎 ...

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

随机推荐

  1. 谈谈对zynq的浅显理解

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

  2. [转载]嵌入式linux启动时运行的inittab文件

    源地址:https://www.cnblogs.com/yfz0/p/5853826.html 嵌入式系统下的linux启动配置文件,不同与普通的PC linux启动配置,启动相关文件与文件的内容也要 ...

  3. struts全包导入问题

    web.xml如下: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=&q ...

  4. Resource interpreted as Document but transferred with MIME type application/json laravel异常请求返回警告

    一般情况下,laravel在方法里可以向前端返回数组格式 return [], 框架可以自动将数组转成JSON字符串返回,但浏览器会报MIME类型警告, 如是做APP接口可以忽视该警告: 但在前端aj ...

  5. vptr, vtable, virtual base class table

    #include <iostream> using namespace std; class X { int x, y, z; }; class Y: public virtual X { ...

  6. Php处理时间的函数

    1,字符串与时间: 例如 $time = strtotime("2007-3-5"); echo date("Y-m-d H:i:s",$time); 2,当前 ...

  7. js获取页面名称和路径参数

    // 取当前页面名称(不带后缀名)function getPageName1(){    var a = location.href;    var b = a.split("/" ...

  8. NodeJS写模块和引入模块的例子

    nodejs自学.js function hello(){ console.log("hello world");} function s(){ console.log(" ...

  9. OD 实验(九) - 对一个程序的破解

    程序: 运行程序 点击 About 这是要注册的 点击 Register 输入邮箱和注册码,点击 Register Now 逆向: 用 OD 打开程序 右键 -> 查找 -> 所有参考文本 ...

  10. django之jquery完成ajax

    使用Ajax 使用视图通过上下文向模板中传递数据,需要先加载完成模板的静态页面,再执行模型代码,生成最张的html,返回给浏览器,这个过程将页面与数据集成到了一起,扩展性差 改进方案:通过ajax的方 ...