[Groovy]引数なしのメソッドを定義する

書式
static def メソッド名()

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
class Example {
 
static def TestFunc() {
println("引数なしのメソットの定義のサンプル");
}
static void main(String[] args) {
TestFunc();
}
}
class Example {   static def TestFunc() { println("引数なしのメソットの定義のサンプル"); } static void main(String[] args) { TestFunc(); } }
class Example {
 
   static def TestFunc() {
      println("引数なしのメソットの定義のサンプル");
   } 
      
   static void main(String[] args) {
     TestFunc();
   } 
}

結果
引数なしのメソットの定義のサンプル

Groovy

Posted by arkgame