如何多次执行Java方法?

1 java loops

我需要第二次运行我的/一个Objects方法.这是允许的吗?我怎样才能做到这一点?

Fab*_*eeg 5

不确定你要做什么,但你可以简单地从自己调用一个方法(它被称为 递归):

void recursiveMethod() {
    System.out.println("Called the recursive method");
    recursiveMethod();
}
Run Code Online (Sandbox Code Playgroud)

调用该方法将打印"Called the recursive method"行,直到出现StackOverflowError.