command-line-arguments-integer
class Cargint
{
public static void main(String[] args)
{
int sum=0;
for(String s:args)
{
int i=Integer.parseInt(s);
sum=sum+i;
}
System.out.println(sum);
}
}
run: java Cargint 10 20 30
output:
60
0 comments:
Post a Comment