0

what is a=integer.parselnt(args[0])?

can anyone explain this

28th Aug 2016, 2:51 AM
Mohd Saqlain
Mohd Saqlain - avatar
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
28th Aug 2016, 3:26 AM
Tiger
Tiger - avatar
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.
28th Aug 2016, 3:34 AM
Mahender
Mahender - avatar
0
above is all right...
28th Aug 2016, 3:36 AM
xinpengfei
0
thanks for all
28th Aug 2016, 4:55 AM
Mohd Saqlain
Mohd Saqlain - avatar