Wednesday 15 May 2024

public static void main(String[] args) explanation


public

is an access modifier
main() declared as globally available
JVM can invoke from outside class


static

JVM can invoke without creating the object.
we can save memory for creating the object.

void

method returns nothing.
as soon as the main method ends then java programs also terminate. So nothing returned by main



main

jvm looks for this identifier for the starting point of the program.
Main method is not a keyword.



String[] args

main method accepts one parameter as String[]
Accepts java command line argument, array of string
args - name of array. we can give any name as user defined.

No comments:

Post a Comment