0
what is a=integer.parselnt(args[0])?
can anyone explain this
4 Answers
+ 1
args are for command-line arguments.
suppose you create a program called isEqual that needs two commad line arguments.
if you run isEqual program and supply two parameters as below:
java isEqual 5 9
Then
args [0] ă 5
args [1] ă 9
As args are String and as the first paramer is an integer you need to convert from String to int
int a=integer.parselnt(args[0]);
Here:
args [0] ă "5"
a ă5
0
Integer.parseInt("string") will convert string argument to number, If given string is not number it will throw exception. Generally java read command line argument in the form of strings so to do any integer manipulations we need to convert atring type to integer type.Hope this helps.
0
above is all right...
0
thanks for all