Description :
This example demonstrate how value accepted from the command line. All argument need to placed at the command line at the time of executing your program.
class CommandLineArgs{
public static void main(String args[]){
intl=args.length;
int sum=0;
for(int j=0;j<
l ;j++){
sum=Integer.parseInt(args[j])+sum;
}
System.out.println("The Sum of All Elements entered at command line is : " + sum);
}
}
output
C:\commandLineArgument>
set path=C:\Program Files\Java\jdk1.6.0_11\bin
C:\commandLineArgument>javac CommandLineArgs.java
C:\commandLineArgument>java CommandLineArgs 12 5
The Sum of All Elements entered at command line is : 17
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.