obj obj1[]=new obj(); //error obj obj1[]=new []obj();

解决方案 »

  1.   

    给你介绍一种方法吧:
    public obj[] function(){
      ArrayList objs = new ArrayList();
      //obj1.Name="mayan";
      //obj1.Age=23;
      for (int i=0;i<2;i++){
      obj obj1=new obj();
      obj1[i].setAge(23);
      obj1[i].setName("Mayan");
      objs.add(obj1);
      }//for
      return (obj[]) objs.toArray(new obj[objs.size()]);
      }
      

  2.   

    发错了,补充下:
    给你介绍一种方法吧:
    public obj[] function(){
      ArrayList objs = new ArrayList();
      //obj1.Name="mayan";
      //obj1.Age=23;
      for (int i=0;i<2;i++){
      obj obj1=new obj();
      obj1.setAge(23);
      obj1.setName("Mayan");
      objs.add(obj1);
      }//for
      return (obj[]) objs.toArray(new obj[objs.size()]);
      }
      

  3.   

    public obj[] function(){
      obj[] objArray = new obj[5];
      for (int i=0;i<5;i++){
      objArray[i]=new obj();
      objArray[i].setAge(23);
      objArray[i].setName("Mayan");
      }//for
      return objArray;
      }
      

  4.   

    public class Untitled2
    {    public static Object[] test()
        {
          Object[] temps = new Object[2];
          temps[0] = new Integer(23);
          temps[1] = new String("WWWWW");
          return temps;
        }    public static void main(String[] args)
        {
            Object[] testValue = test();
            System.out.println(testValue[0]);
            System.out.println(testValue[1]);
        }
    }
      

  5.   

    看错题意。重来!  public obj[] function(){
      obj[] obj1=new obj[2];---------------〉此处修改
      //obj1.Name="mayan";
      //obj1.Age=23;
      for (int i=0;i<2;i++){
      obj1[i].setAge(23);
      obj1[i].setName("Mayan");  }//for
      return obj1;
      }
      

  6.   

    obj[] obj1=new obj[2];---------------〉此处修改
    OK