Topic: 一點點疑問 (public static void main(String[] args) 的String[] args是做什麼) |
Print this page |
1.一點點疑問 (public static void main(String[] args) 的String[] args是做什麼) | Copy to clipboard |
Posted by: dwju Posted on: 2002-11-26 22:17 Public static void main(String[] args) 這句話在很多程序中都有,我知道是標識程序開始的main方法,但是對其參數String[] args 不是很明白,找一些參考書也沒有講,這個是做什麼用的? 謝謝先! |
2.my answer [Re: dwju] | Copy to clipboard |
Posted by: rainman Posted on: 2002-11-27 02:25 you may run a java class in this way: c:\>java YourClass arg0 arg1 arg2 so args[0] = arg0 args[1] = arg1 args[2] = args2 ok? |
3.程序启动的参数 [Re: dwju] | Copy to clipboard |
Posted by: 烂泥 Posted on: 2002-11-27 19:25 这个数组收集了命令行的参数 比如 DOs下的 dir /a /w /a ,/w 就是存放在该数组中 |
4.Re:一點點疑問 [Re: dwju] | Copy to clipboard |
Posted by: dwju Posted on: 2002-11-27 23:45 明白了,謝謝…… |
5.Re:一點點疑問 (public static void main(String[] args) 的String[] args是做什麼) [Re: dwju] | Copy to clipboard |
Posted by: hong1993 Posted on: 2004-11-30 13:34 Now ,let's look at an example public class Example { public static void main(String[] args) { for(int i=0;i<args.length;i++) { System.out.println(args[i]); } } } compile javac Example.java run java Example one two three four one two three four OK,I think you have already Known it |
6.Re:一點點疑問 (public static void main(String[] args) 的String[] args是做什麼) [Re: dwju] | Copy to clipboard |
Posted by: crazip Posted on: 2004-12-01 12:22 谢谢了,我明白了,就是一个命令的参数。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |