[Training Video - 4] [Groovy] Function in detail
Employee.log=log Employee e1 = new Employee()
Employee e2 = new Employee()
e1.name = "A"
e1.salary = 100 e2.name = "B"
e2.salary = 200 e1.printName()
e2.printName()
def newSalary = e1.increaseSalary(100)
log.info "New salary of A is $newSalary"
e2.increaseSalary(100) log.info "Salary of $e1.name is $e1.salary"
log.info "Salary of $e2.name is $e2.salary" class Employee {
def static log
def name
def salary public void printName(){
log.info name
} public int increaseSalary(amt){
salary = salary+amt
return salary
}
}
Run Result:
Tue Oct 06 19:24:47 CST 2015:INFO:A
Tue Oct 06 19:24:47 CST 2015:INFO:B
Tue Oct 06 19:24:47 CST 2015:INFO:New salary of A is 200
Tue Oct 06 19:24:47 CST 2015:INFO:Salary of A is 200
Tue Oct 06 19:24:47 CST 2015:INFO:Salary of B is 300
[Training Video - 4] [Groovy] Function in detail的更多相关文章
- [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] 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() ...
- [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 - 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] 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 - 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" ...
- [Training Video - 4] [Groovy] String Functions
def x="I like to read books before bed" def temp = x.split(" ") log.info "S ...
随机推荐
- Spring security 如何设置才能避免拦截到静态资源
问题:继承FilterSecurityInterceptor自定义Spring security拦截器,但是每次都拦截了css等静态资源,应该如何设置? @Override protected voi ...
- Appium+python自动化23-Android夜神模拟器
前言 Android SDK虽然也自带了模拟器,但是那速度会让你怀疑人生,并且不稳定经常卡死异常.夜神模拟器可以说是android模拟器里面的一个神器. 环境安装 1.官网下载地址:https://w ...
- java代码--实现随机输出10个随机数,并显示最大值,最小值
总结;对于length()属性,还不是很熟悉.不会用它. package com.s.x; //随机产生10个随机数,并且显示出最大值,最小值 public class Love { public s ...
- 给scrapy添加代理IP
request.meta['proxy'] = 'http://'+'175.42.123.111:33995'
- hadoop map端的超时参数
目前集群上某台机器卡住导致出现大量的Map端任务FAIL,当定位到具体的机器上时,无法ssh或进去后terminal中无响应,退出的相关信息如下: [hadoop@xxx ~]$ Received d ...
- Hive使用入门
Hive简介 hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供简单的sql查询功能,可以将sql语句转换为MapReduce任务进行运行. 其优点是学习成 ...
- VMware 虚拟机中添加新硬盘的方法(转载)
随着在虚拟机中存储的东西的逐渐的增加,虚拟机的硬盘也逐渐告急,因此急需拓展一块新的虚拟磁盘.以下便是在VMware 中添加新的虚拟磁盘的方法: 一.VMware新增磁盘的设置步骤 (建议:在设置虚 ...
- springcloud (一) 介绍
开启springcloud 之旅... 传统单体架构: 微服务架构: 每个模块独立运行,就是独立的进程. 接下来基于springboot 来构建微服务: 1, 客户端->订单微服务->用户 ...
- 关于jquery.noConflict()的学习记录
今天无意中看到了jquery.noConfict()的实现方法 代码如下: var // Map over jQuery in case of overwrite _jQuery = window.j ...
- IOS 阻止 锁屏
[UIApplication sharedApplication].idleTimerDisabled=YES;不自动锁屏 idleTimerDisabled