[Groovy]引数ありのメソッドを定義する

書式
staic void メソッド名(引数1,引数2…)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
class Example {
static void sumFunc(int x, int y, int z) {
int res = x + y -z;
println(res)
}
static void main(String[] args) {
sumFunc(3,8,2);
}
}
class Example { static void sumFunc(int x, int y, int z) { int res = x + y -z; println(res) } static void main(String[] args) { sumFunc(3,8,2); } }
class Example {

   static void sumFunc(int x, int y, int z) {
     int res = x + y -z;
     println(res)
   } 
      
   static void main(String[] args) {
     sumFunc(3,8,2);
   } 
}

結果 9

Groovy

Posted by arkgame