java中的命令行参数 [英] command line arguments in java
问题描述
我是java新手,想知道如何获取几个命令行参数并对它们求和。我已经这样做了两个数字 - 但不知道该怎么做。谢谢
Hi, I''m new to java and would like to know how to take several command line arguments and sum them . I have done so for two numbers- but don''t know how to go on. Thanks
推荐答案
我我是java的新手,想知道如何获取几个命令行参数并对它们求和。我已经这样做了两个数字 - 但不知道该怎么做。谢谢
Hi, I''m new to java and would like to know how to take several command line arguments and sum them . I have done so for two numbers- but don''t know how to go on. Thanks
尝试编译时遇到什么错误?
-blazed
What errors are you getting when trying to compile this?
-blazed
我没有得到任何错误,但这个程序仅添加两个数字,我想要知道如何添加三个或五个或任何数字
Im not gettin any errors ,but this programm does the addition for only two numbers and i want to know how to add for three or five or whatever numbers
我没有得到任何错误,但这个程序仅添加两个数字,我想知道如何添加三个或五个或任何数字
Im not gettin any errors ,but this programm does the addition for only two numbers and i want to know how to add for three or five or whatever numbers
注意:复制的消息让用户知道我发布了。
嗯...认为你的问题那是不行的。没有完全读完,抱歉。
用(int i = 0; i< args.length; i ++){/ *声明total = 0之前*进行for循环* / total + = Integer.parse(args [i])
这有帮助吗?
-blazed
Note: message copied so user knows I posted.
Um... Thought your problem was that didn''t work. Didn''t read completely, sorry.
Make a for loop with (int i = 0; i < args.length; i++) { /*declare total=0 earlier*/ total+=Integer.parse(args[i])
Does that help?
-blazed
这篇关于java中的命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!