大佬教程收集整理的这篇文章主要介绍了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 (";"); } }
以上是大佬教程为你收集整理的groovy之基础篇全部内容,希望文章能够帮你解决groovy之基础篇所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。