X hits on this document

153 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 views153
Page views153
Page last viewedSat Jan 21 00:22:53 UTC 2017
Pages46
Paragraphs816
Words2901

Comments