Shu[] k=new Shu[5];没错,但只是声明了一个数组,里面什么对象也没有。
可以如下:
for(int i=0;i<5;i++)
{
   k[i] = new Shu();
}

解决方案 »

  1.   

    : grgh2000(太阳) 兄,不行呀,它说:Test.java [20:1] non-static variable this cannot be referenced from a static context
    我连
    k[0]=new Shu();
    k[1]=new Shu();
    这样也不行!
      

  2.   

    楼上的应该是在main函数中引用this了吧。
    不然怎么会出这样的错误提示?
      

  3.   

    class Shu{
      int i;
      float f;
     }
    public class Test{
    public static void main(String[] args){
    Shu[] k=new Shu[5];
    k[0]=new Shu();
    k[1]=new Shu();k[0].i=1;
    k[1].i=2; 
    System.out.print(k[0].i+"");
    System.out.print(k[1].i+""); 
     }
    }