202107280944 - 在java代码中调用scala函数

scala对象

object ScalaDemo {  
  
  def add(a :Int, b :Int) :Int =  
    a + b  
  
}

java代码

public class Test {  
  
    public static void main(String[] args) {  
  
        int add = ScalaDemo.add(1, 2);  
  
 System.out.println(add);  
  
 }  
  
}
posted @ 2025-03-19 21:55  钱塘江畔  阅读(15)  评论(0)    收藏  举报