且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Groovy脚本中创建类

更新时间:2023-12-05 15:05:16

in groovy脚本你可以声明和访问它的静态方法,如下所示:

in groovy script you can declare and access static methods of it like this:

class A{
    static void greet(String name){
        println "hello $name!"
    }
}

//code without class declaration will be executed as part of script.run() method 
A.greet("world")