Java program – command-line argument

by Nideesh C on April 28, 2011 · 0 comments

in Java Programming




public class UseArgument {

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

}


/******************** ***************** ****************************/
 *  Execution:    java UseArgument yourname
 *
 *  Prints "Hi, Alan. How are you?" where "Alan" is replaced by the
 *  command-line argument.
 *
 *  % java UseArgument Alan
 *  Hi, Alan. How are you?
 *
 *  % java UseArgument Jose
 *  Hi, Jose. How are you?
 *
 ********************* **************** ****************************/



Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Java program – Converting to binary
  2. Java program – Factoring integers
  3. Java program – Harmonic numbers
  4. Java program – Newton’s method
  5. Java program – Computing powers of two

Leave a Comment

Previous post:

Next post: