public class Test {
public static void maoBao(int[] x) {  
  for (int i = 0; i < x.length; i++) {  
   for (int j = i + 1; j < x.length; j++) {  
    if (x[i] > x[j]) {  
     int temp = x[i];  
     x[i] = x[j];  
     x[j] = temp;  
    }  
   }  
  }  
  for (int i : x) {  
   System.out.print(i + " ");  
  }  
 }
  public static void main(String[] args) {
   Test paly = new Test();
   int[] a = {1,9,0,6,7,3,};
   paly.maoPao(a);
   }}
这个程序有什么问题?

解决方案 »

  1.   


      int[] a = new int[]{1,9,0,6,7,3};
      Test.maoBao(a);
      

  2.   

    LS说的不是问题,可以不new,问题出在maoBao这个方法名,你用的时候是maoPao
    看出区别了?LZ的编译环境没有提示?
      

  3.   

    第一不用new对象,类名.静态方法名就可以,第二方法名写错了吧
      

  4.   

    在new的时候不会通过编译的,直接调用就可以了
      

  5.   

    静态方法直接用类名调用就可以了,不需要再定义对象来调用,还有就是一个小错误,maoBao而不是maoPao
      

  6.   

    NEW对象是没有问题的,问题就是你的那个调用的时候那个方法名写错了。静态也是可以NEW出来的。LZ大概是用TXT编写的,改成 paly.maoBao(a);就没有问题了。