当前位置: 代码迷 >> Java相关 >> TO Anstey
  详细解决方案

TO Anstey

热度:441   发布时间:2004-09-08 21:35:00.0
TO Anstey

这为高手,我想你理解错了我的问题,我主要是想问参数的问题,前面的两个我都解决了,我想问问你main都有什么参数,都代表什么含义

搜索更多相关的解决方案: Anstey  

----------------解决方案--------------------------------------------------------

对不起,误解你的问题了。。。呵呵。。。 main method的参数应该是一个array of Strings,写程序的时候,我们用 public static void main(String[] args){} //String[] args就是参数 这个array在程序执行时,用来储存任何用户在command line输入的arguments。 这个参数不常用,只有在FileReader,BufferedReader,PrintWriter,FileInputStream..的时候常用(用来打开用户所指定的文件夹) 用一个小小的列子来解释: public class Example{ public static void main(String[] args){ if (args.length == 0) System.out.println("No argument specified!"); else System.out.println(args[0]+" "+args[1]);// this is where we use the parameter "args" } }

如果在command line执行上面程序的时候:

C:\javaPrograms\java Example Hello jasnowing27

args[0]就是 Hello, args[1]就是jasnowing27

output will be:

Hello jasnowing27

不知道是否回答你的问题。SORRY for misunderstanding your question again... by the way: Anstey<<<<<< NOT 高手。。。


----------------解决方案--------------------------------------------------------
  相关解决方案