• The group of strings what we are passing as an argument to the main method from the console or command line are known as command line arguments.
  • Every command line argument would be accepted by the JVM in the form of a String object.
  • JVM will always executes main method by passing object of an array of strings.
  • JVM would never execute main method by passing null
  • JVM always executes main as a thread. 

 

Program on command line arguments:

package com.instanceofjavaforus;

public class CommandLineArguents {

    public static void main(String args[]){
      
        System.out.println("Your first argument is: "+args[0]);
    }
  
}

  • >javac CommandLineArguent.java

    >java CommandLineArguents

    OutPut:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at com.instanceofjavaforus.CommandLineArguents.main(CommandLineArguents.java:8)
  • >javac CommandLineArguent.java

    >java CommandLineArguents  instance

    OutPut:
    instance

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu