Reputation: 89
This is the question which I got "Write a program to read and display 2 command line arguments and the length of the command line argument array."
This is my answer in Java..Is this correct ?
int length = args.length;
for(int i = 0;i<length; i++)
{
System.out.println(args[i]);
}
System.out.println("Length is " + args.length);
}
Upvotes: 0
Views: 5678
Reputation: 2531
You should only display 2 arguments?
for(int i = 0; i< args.length && i < 2; i++)
{
System.out.println(args[i]);
}
System.out.println("Length is " + args.length);
Upvotes: 3