Bank.log = log

Bank b1 = new Bank()
b1.name = "BOA"
b1.minbalance = 100
b1.city="London" Bank b2 = new Bank()
b2.name = "HSBC"
b2.minbalance = 100
b2.city="LA" Bank b3 = new Bank("A",100,"X")
log.info b3.name
Bank b4 = new Bank("B",1200,"X1")
Bank b5 = new Bank("C",1300,"X2")
log.info b5.minbalance class Bank{
def static log
def name
def minbalance
def city public Bank(){ // no return type, same name with class name
log.info "inside constructor"
} // public Bank(bankName,bankMinBal,bankCity){
// name = bankName
// minbalance = bankMinBal
// city = bankCity
// } public Bank(name,minbalance,city){
this.name = name
this.minbalance = minbalance
this.city = city
}
}

Run result:

Tue Oct 06 19:51:29 CST 2015:INFO:inside constructor
Tue Oct 06 19:51:29 CST 2015:INFO:inside constructor
Tue Oct 06 19:51:29 CST 2015:INFO:A
Tue Oct 06 19:51:29 CST 2015:INFO:1300

[Training Video - 4] [Groovy] Constructors in groovy, this keyword的更多相关文章

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

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

  2. Error:Cannot compile Groovy files: no Groovy library is defined for module 'xxxx' 错误处理

    出现 Error:Cannot compile Groovy files: no Groovy library is defined for module 'xxxx' 只要在 project str ...

  3. Groovy学习记录-------Groovy安装/配置

    1.Groovy SDK下载 Groovy SDK官网下载地址: http://www.groovy-lang.org/download.html  每个版本有五个选项可供下载,依次为: binary ...

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

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

  7. [Training Video - 6] [File Reading] [Groovy] Reading Properties file

    Reading Properties file : Properties prop = new Properties() def path = "D:\\SoapUIStudy\\appli ...

  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. springMvc架构简介

    什么是spring 关于spring的定义无论是从官方还是市面上已经很多能够清晰明了的做出解释了.我姑且简单定义它为一个轻量级的控制反转(IoC)和面向切面(AOP)的容器,Java 开发框架,至于控 ...

  2. 如何安装nginx第三方模块

    nginx文件非常小但是性能非常的高效,这方面完胜apache,nginx文件小的一个原因之一是nginx自带的功能相对较少,好在nginx允许第三方模块,第三方模块使得nginx越发的强大. 在安装 ...

  3. struts2学习(14)struts2文件上传和下载(4)多个文件上传和下载

    四.多个文件上传: 五.struts2文件下载: 多个文件上传action com.cy.action.FilesUploadAction.java: package com.cy.action; i ...

  4. python--logging库学习_第三波

    本文介绍如何写一个Python日志类,用来输出不同级别的日志信息到本地文件夹下的日志文件里.为什么需要日志输出呢,我们需要记录我们测试脚本到底做了什么事情,最好的办法是写事件监听.这个事件监听,对我们 ...

  5. java代码--------打印三角形

    总结:这里主要是for循环里的j<=i而不死j<=i-1;.还有先打印“*” 再打印空格.换行.理解.请用脑子啊 package com.sads; public class Dds { ...

  6. C++:const_cast类型转换

    针对const_cast,太多人在用同一个示例问同一个问题:void main(){   const int a = 3;   const int *pc = &a;   int *p = c ...

  7. Oracle数据库学习笔记(一)

      Oracle的体系结构大体上分为两部分:Instance(实例)和Database(数据库). Instance(实例) :在Oracle Instance中主要包含了SGA以及一些进程(例如:P ...

  8. 启动tomcat服务器,配置CATALINA_HOME和JAVA_HOME

    遇到很多次运行startup.bat后,一个窗口一闪而过的问题,但是从来没去纠正怎样修改配置才是正确的,现在从网上查阅的资料整理如下:tomcat在启动时,会读取环境变量的信息,需要一个CATALIN ...

  9. 【CVE】CVE-2018-4304 Apple多个操作系统函数拒绝服务漏洞

    TextImpact: Processing a maliciously crafted text file may lead to adenial of serviceDescription: A ...

  10. Java--神奇的hashcode

    一.Object的HashCode定义 public native int hashCode(); Object类的hashCode方式使用了native修饰也就意味着真正的实现调用的其他语言编写的方 ...