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. rails里面添加妹子ui

    妹子ui看起来很不错,以为在rails里面添加自定义的css和js和平时一样,结果可想而知,不过弄完以后发现还是比较简单的,这里记录一下 妹子ui需要加载的css和js如下 http://cdn.am ...

  2. python-错误

    错误 Exception happened during processing of request from ('10.0.0.120', 58083) Traceback (most recent ...

  3. “FPGA+云"助力高性能计算

    用AI防鲨鱼.用AI学写中国书法.用AI预测人类死亡时间.用AI审判罪犯……在人工智能方兴未艾的今天,越来越廉价和普及的AI领域真的是什么都不值钱,除了想象力.那在这无所不能的AI盛世,一定没道理让算 ...

  4. Appium Hybrid混合应用测试——Native切换WebView , 切换不了WebView (没有试过,先记录在此)

    Appium Hybrid混合应用测试过程中,经常需要在Native和WebView之间进行切换: 1.切换至WEBVIEW操作: for cons in driver.contexts: if co ...

  5. java代码----数据类型的转换-----int --->String

    总结:int ----->String package com.a.b; //测试..char--->int // int--->String public class Yue2 { ...

  6. 018:InnoDB 存储引擎、表空间

    目录 一.InnoDB 存储引擎 1. InnoDB的历史 2. InnoDB的特点 3. InnoDB存储引擎的文件 3.1 概述 3.2 InnoDB - 表空间 3.3 General表空间 3 ...

  7. 第十章 Secret & Configmap (中)

    10.3 在Pod中使用Secret 10.3.1 Volume方式 apiVersion: v1 kind: Pod metaata: name: mypod spec: containers: - ...

  8. 【洛谷】P1052 过河(状压dp)

    题目描述 在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧.在桥上有一些石子,青蛙很讨厌踩在这些石子上.由于桥的长度和青蛙一次跳过的距离都是正整数,我们可以把独木桥上青蛙可能到达的点看成数 ...

  9. jQuery样式与动画

    修改内联CSS .css() 获取 //取得单个属性的值,传入'属性名',返回"value" .css('property') //取得多个属性的值,传入'['属性1','属性2' ...

  10. TypeScript--deno前置学习

    第一节:前言: 1.JavaScript 的发展简史图: 2.关于node与deno: (1)Node与Deno 的区别:Node 可以工作,而 Deno 不行,Deno 只是一个原型或实验性产品. ...