Main Method

The Main method is the entry point of every Java program. It is a static method and accepts parameters that can be passed to it from the command line. Here is the standard declaration for the Main method:

public static void main(String[] args)

Command line arguments are passed as an array of strings. Thus, to access the first command line argument, you would use code like this:

String parm1 = args[0];

Get Java For Dummies Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.