public class PaiXu implements Runnable
{
static int sz[];
public static void main(String args[])
{
for (int i=0;i<args.length;i++)
{
try{
sz[i]=Integer.parseInt(args[i]);
}catch(Exception e){}
System.out.print(sz[i]+" ");
}
PaiXu ss=new PaiXu();
Thread pai=new Thread(ss);
pai.start();
}
public void run()
{
for (int i=0;i<sz.length;i++)
{
for (int j=0;j<sz.length-1;j++)
{
if (sz[j]<sz[j+1])
{
int a=sz[i];
sz[i]=sz[j];
sz[j]=a;
}
}
}
for (int i=0;i<sz.length;i++)
{
System.out.print(sz[i]+" ");
}
}
}
上面是源程序,用来排序的,编译能通过,
D:\JAVA\console>javac PaiXu.java
可执行时会提示以下错误
D:\JAVA\console>java PaiXu 23 34
Exception in thread "main" java.lang.NullPointerException
at PaiXu.main(PaiXu.java:11)
[此贴子已经被作者于2006-2-26 11:19:27编辑过]