[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()
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的更多相关文章
- [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() ...
- [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() ...
- [Training Video - 4] [Groovy] Function in detail
Employee.log=log Employee e1 = new Employee() Employee e2 = new Employee() e1.name = "A" e ...
- [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 ...
- [Training Video - 2] [Groovy Introduction]
Building test suites, Test cases and Test steps in SOAP UI Levels : test step level test case level ...
- [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 ...
- [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 ...
- [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 ...
- [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" ...
随机推荐
- Unit01: Servlet基础 、 HTTP协议
Unit01: Servlet基础 . HTTP协议 在页面上输出当前时间 package web; import java.io.IOException; import java.io.PrintW ...
- table tr列 鼠标经过时更改背景颜色
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- Java中如何查看一个类依赖的包
Java中如何查看一个类依赖的包 如图, 我如何知道JSONArray是依赖的哪一个包呢,这里有两个json-lib包? 测试语句: public static void main(Strin ...
- POJ2739(尺取法)
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 23931 ...
- Java将对象写入文件读出——序列化与反序列化
Java类中对象的序列化工作是通过ObjectOutputStream和ObjectInputStream来完成的. 写入: File aFile=new File("e:\\c.txt&q ...
- cordova 安装使用
前人总结: Cordova是Apache软件基金会的一个产品.其前身是PhoneGap,由Nitobi开发,2011年10月,Adobe收够了Nitobi,并且PhoneGap项目也被贡献给Apach ...
- python--logging库学习_自我总结---有空完善
思路: 1.把前面的都封装,然后在测试用例里面调用,每一步测试步骤下面都加一个 logging.info('这个是测试步骤')(可以 亲测) 2.尝试添加到unittest框架里面,看能不能一起使用 ...
- lamp与lnmp的选择
lnmp和lamp业务上的不同 由于二者仅仅是区别在于web的选择,nginx更高效,占用资源更少,详情区别查看LNMP环境应用实践 lnmp和lamp安装上的不同 生产环境中,可能会遇到lamp架构 ...
- ALSA声卡笔记3--ASoC驱动重要结构体关系图
1.ASoC中重要的数据结构之间的关联方式 (1)Kernel-2.6.35-ASoC中各个结构的静态关系 ASoC把声卡实现为一个Platform Device,然后利用Platform_devic ...
- Web App、Hybrid App与Native App的设计差异
目前主流应用程序大体分为三类:Web App.Hybrid App. Native App. 一.Web App.Hybrid App.Native App 纵向对比 首先,我们来看看什么是 Web ...