In c++ we write main function at last and in c if there are any forward function calls we will declare functions in the beginning or we will define all the functions first then we will write main function. But in java even if we write main method in the beginning then other methods and if we call other methods from main method..it wll execute..why? How will it come to know there is some method defined in the program?
class Temp{
public static void main(String args[]){
display();
}
public static void display(){
System.out.println("HI");
}
}