Microsoft Dot Net Master

Microsoft Dot Net Master
Microsoft Dot Net Master

Thursday, February 2, 2017

What does each term in "public static void main(String[] args)" mean?

public is the visibility. This can be public, private, protected or (if you omit a value) default.
static is a special [optional] keyword that indicates that this method can be called without creating an instance of this class. Without it, you have to instantiate this class and call this method from the resulting object.
void is the return type of this method, indicating that this method doesn't return anything. Methods must have a return type.
main( ... ) is the name of this method. Methods have to be named. The parentheses indicate that this is a method.main() is special because it is the start of the program.
String[] args is a single parameter for the method. String[] is the type of the parameter, indicating an array of Strings. args is the name of the parameter. Parameters must be named.

No comments:

Post a Comment