X hits on this document

115 views

0 shares

0 downloads

0 comments

38 / 46

© S. Uchitel, 2004

38

Passing arguments to main()

The main method should be always be declared

public, static, of type void, and

with a String array as a parameter: stores arguments included in the command line call of the program

c:\> java ShowArgs Hello World from Java <ENTER>  

Hello

World

from

Java

class ShowArgs {

 public static void main( String args[] ) {

   int i;

   for ( i = 0; i < args.length; i++ )

     System.out.println(args[i]);

 }

}

Document info
Document views115
Page views115
Page last viewedThu Dec 08 19:33:40 UTC 2016
Pages46
Paragraphs816
Words2901

Comments