skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

▼
 
  • RSS
  • Twitter
Friday, January 6, 2012

Command Line Argument in JAVA | Java Program

Posted by Admin at 2:22 AM – 0 comments
 
Following Java Program will show how to take Command Line Argument in JAVA.

/*************************************************************************
 *
 *  Prints "Hi, Sam. How are you?" where "Sam" is replaced by the
 *  command-line argument.
 *
 *************************************************************************/

public class UseArgument {

    public static void main(String[] args) {
        System.out.print("Hi, ");
        System.out.print(args[0]);
        System.out.println(". How are you?");
    }

}

/***************************  
 * Program Output
 *
 *  % java UseArgument Bob
 *  Hi, Bob. How are you?
 *
 *  % java UseArgument Alice
 *  Hi, Alice. How are you?
 ***************************/ 
Labels: Basic Java Programs , Command Line Argument

Leave a Reply

Newer Post Older Post
Subscribe to: Post Comments ( Atom )
  • Popular
  • Recent
  • Archives
Powered by Blogger.
 
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger