请问如何输入命令行参数?
我使用的是JCreator 2.5 Proi软件编程。请教在Java中如何输入命令行参数?谢谢! 我的代码如下:
class Hal
{
public static void main(String[] args)
{
int year=2002;
int month=12;
if(args.length>0)
month=Integer.parseInt(args[0]);
if(args.length>1)
year=Integer.parseInt(args[1]);
System.out.println(month+"/"+year+" has "+count(month,year)+" days");
}
static int count(int month,int year)
{
int count=-1;
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
count=31;
break;
case 4:
case 6:
case 9:
case 11:
count=30;
break;
case 2:
if(year%4==0)
count=29;
else
count=28;
if((year%100==0) & (year%400!=0))
count=28;
}
return count;
}
}
[此贴子已经被作者于2005-12-5 10:49:17编辑过]