obj obj1[]=new obj(); //error obj obj1[]=new []obj();
解决方案 »
- 新手关于枚举类的一点疑惑,求高手解答!
- 请问swing如何持久化??
- java中的接口问题
- 我们的网站访问量很大,同时并发可能有100多人访问数据库,但如果这时候有1个人在往一张表里写数据,那么mysql就会把整张表锁定,这时其它99
- 如何利用java.util.List接口创建二维或三位数组啊?
- 请问,哪里有Together下载?
- 今天上了十几次都是服务器尽快,终于上来的,问一下如何完全从电脑上卸载JVM?
- @@@@@@ java程序员passport大调查!@@@@@@@
- 我用JBuider2.0作的含swing类的applet,ie5.5增么都看不见?奇怪
- 小白求教多线程问题!麻烦了!
- 急--一个java数据库方面的问题
- 请问怎样在eclipse环境中运行带参数的java程序?
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()]);
}
给你介绍一种方法吧:
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()]);
}
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;
}
{ 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]);
}
}
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;
}
OK