以 groovy 的方式实现接口

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

//如果接口只有一个方法,可以通过闭包,用下面的方式来实现:

 // a readable puts chars into a CharBuffer and returns the count of chars added
def readable = { it.put("12 34".reverse()); 5 } as Readable

// the Scanner constructor can take a Readable
def s = new Scanner(readable)
assert s.nextInt() == 43