+ 3
Is main() a user-defined function or a predefined function ?
We do write content in main() but we can't name the main function anything, we have to name it main(). Then what is main() user-defined or predefined?
5 Respuestas
+ 5
The jvm searches for a method called main as a starting point to begin executing your code, it only knows that there should be a main method somewere in one of your classes so yes you need to define it as it's not built in.
+ 3
I see, now it makes sense to me. Thanks for clarification.
+ 3
It can be considered as a starting point for the program because the control flow in C starts with main() rather like languages as python will execute the code line by line.
Main() cannot be considered as a predefined function because the user himself should write it's definition. And it is not completely user defined because the compiler pre-declared it. In c main is not a keyword as it can be used as a variable name also.
+ 2
So is it predefined or user-defined or both?