log.info "starting"

// we use class to create  objects of a class
Planet p1 = new Planet()
Planet p2 = new Planet() //Planet.name = "Pluto" illegal
Planet.shape = "Circle" // static variable
Planet.log = log p1.name = "earth" // non static variable
p2.name = "jupiter" p1.printName() // non static has to be called with reference
Planet.revolve() // static can be called with class class Planet{
// variables and functions
def name // non static variable
def static shape // static variable
def static log public void printName(){ // non static function
log.info ("Name of planet is $name. Shape is $shape")
xyz() // non static can access static
} public static void revolve(){ // static function
//log.info (name) // error, static cannot access non static
xyz() // call one function from another function
log.info ("Planet revolving. Shape is $shape")
} public static void xyz(){
log.info "inside xyz"
}
}

Test Result:

Tue Oct 06 18:30:29 CST 2015:INFO:starting
Tue Oct 06 18:30:29 CST 2015:INFO:Name of planet is earth. Shape is Circle
Tue Oct 06 18:30:29 CST 2015:INFO:inside xyz
Tue Oct 06 18:30:29 CST 2015:INFO:inside xyz
Tue Oct 06 18:30:29 CST 2015:INFO:Planet revolving. Shape is Circle

 Note :

Static cannot access non static

[Training Video - 3] [Groovy in Detail] Non-static and Static functions, initializing log inside class的更多相关文章

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

  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. Zookeeper--配置服务

    Zookeeper--配置服务 配置服务是分布式应用中重要的服务,作用是使集群中的机器可以共享配置信息中公共的部分.ZooKeeper可作为一个具有高可用,全局一致的配置服务器,允许客户端获取和更新配 ...

  2. 慢日志之二:ERROR 1146 (42S02): Table 'mysql.slow_log' doesn't exist,分析诊断工具之四

    去查看最新的slow log,发现没有最新的记录,上去检查slow log是否开启了. MySQL> show variables like '%slow%'; +--------------- ...

  3. python中scipy学习——随机稀疏矩阵及操作

    1.生成随机稀疏矩阵: scipy中生成随机稀疏矩阵的函数如下: scipy.sparse.rand(m,n,density,format,dtype,random_state) 1 参数介绍: 参数 ...

  4. POJ 3279 Fliptile(反转 +二进制枚举)

    Fliptile Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13631   Accepted: 5027 Descrip ...

  5. PHP环境基础配置

    域名访问设置(本地局域网) 用记事本打开 127.0.0.1是本地回环地址 配置完后 通过在本地浏览器输入www.0705.com就可以访问本地站点了 Wamp集成环境多站点配置 配置条件: 一个服务 ...

  6. 查看Android内存,cpu

    转自https://testerhome.com/topics/2583 一.查看内存 查看Android应用内存: adb shell dumpsys meminfo 1.查看详细的内存: adb ...

  7. SpringData JPA 接口和方法

    1.1 简单查询--接口方法 1.2 五个接口详解 1.2.1    CrudRepository接口 其中T是要操作的实体类,ID是实体类主键的类型.该接口提供了11个常用操作方法. @NoRepo ...

  8. mysql 锁 事务隔离级别

    主题 最近在看mysql相关的书籍.实验了一些内容.分享一下,主要是关于事务隔离级别(read-committed和repeatable-read)和锁相关的. 很多网上文章上都能搜索到 read-c ...

  9. 【312】◀▶ arcpy 常用函数说明

    其他常用的 ArcPy 函数说明 序号 类名称   功能说明   语法 & 举例 01 RefreshActiveView   ====<<<< Description ...

  10. Sqlserver ROW_NUMBER()

    SELECT ROW_NUMBER() OVER (ORDER BY A.orderdate,A.orderid),* from Sales.Orders A