groovy之基础篇
package fist
class HelloWorld { static main(args) { println("===========HelloWorld "+new java.util.Date()); System.out.println("HI GROOVY"); def var="YES"; println var; println var.class; var=1000; println var.class; println("MAP------------------"); def map=['name':'VerRan','age':'25']; println map['name']; println map.age; map.wife='dove'; println map.wife; map.each({println it}); map.each({key,value->println "$key:$value"}); println("Collect集合------------------"); def collect=['a','b','c']; println collect[1]; println collect.size; println collect[-2]; println("闭包------------------"); def say={world-> println "come on 闭包,$world"; } say("HIIIIIIII"); } }
class Sencod extends GroovyTestCase { public void test(){ def animals=['dog','maomi','caw','cat']; assert animals.size()==4; assert animals.get(1)=="maomi"; def add={ a,b-> return a+b; } def c=add.call(1,2); assert c==3; def values=animals.find{it.size()>3}; assert values=="maomi"; println animals.every({it.size()>3}); println animals.any({it.size()>3}); println animals.min(); println animals.max(); println animals.join (";"); } }
相关推荐
软件的信雅达 2020-11-02
糖葫芦娃哈哈 2020-11-02
淡茶 2020-05-10
PHP学习笔记 2020-03-06
anvien 2020-01-08
quzhongwei 2020-01-06
淡茶 2020-01-03
tysforwork 2019-12-12
简单点好 2013-09-04
PeterHao0 2013-08-31
软件的信雅达 2019-11-19
软件的信雅达 2017-02-11
yiyilanmei 2015-04-28
无聊找点事做 2019-09-06
HaleyJenkins 2016-10-18
PeterHao0 2016-01-22
dieefer 2017-02-11
liushidexing 2016-11-03
春天花会开 2016-11-01