关于java方法调用

Rak*_*noy 2 java

在c ++中我们最后编写main函数,在c中如果有任何正向函数调用,我们将在开头声明函数,或者我们将首先定义所有函数然后我们将编写main函数.但是在java中,即使我们在开头编写main方法然后是其他方法,如果我们从main方法中调用其他方法,那么会执行..Why?如何知道程序中定义了一些方法?

class Temp{

    public static void main(String args[]){

      display();

    }

    public static void display(){

       System.out.println("HI");

    }
}
Run Code Online (Sandbox Code Playgroud)

hel*_*ker 6

与C++不同,我们不需要Java中的前向声明.标识符(类和方法名称)将自动从源文件中识别

http://www.geeksforgeeks.org/do-we-need-forward-declarations-in-java/