【发布时间】:2021-05-14 00:55:24
【问题描述】:
我有一段非常简单的代码,我在其中调用了我定义的方法,但它不会运行,因为它说我还没有定义方法?
class Main {
public static void main(String[] args) {
go(7,3);
}
} /// 在名为 go.java 的单独文件中 -->
class go{
public static int go(int x, int y){
if(x <= 1)
return y;
else
return go(x - 1, y) + y;
} }
【问题讨论】:
-
请提供minimal reproducible example,这看起来不像您的所有相关代码。也许这就是问题所在,但必须澄清这一点。
标签: java loops if-statement file-structure