Passing command line arguments in java
1. check the number argument's passed, exit the program with status success when you received insufficient command line arguments.
if(args.length==0){
System.out.println("Insufficient Arguments..");
System.exit(0);
}
2. Parse the arguments to Integer from String.
System.out.print("sum="+Integer.parseInt(arg1)+Integer.parseInt(arg2));
for complete code click here.
No comments:
Post a Comment