void Createdata(){
myclass[] x=new myclass[10];
x[0].a=1;
}这个是干什么的啊? 啥都米做,数组外面又不能用
myclass[] x=new myclass[10];
x[0].a=1;
}这个是干什么的啊? 啥都米做,数组外面又不能用
解决方案 »
- 读取日志文件
- Hibernate 单向一对多,添加数据出现"违返完整性约束"
- 在项目的xml中里面有这么一段代码
- jsp做中英文网站的数据库大家怎么设计的?
- 请问怎样在log4j.properties中设置spring和hibernate log输出的级别?
- jfreechart 数据点显示的问题
- 我在使用struts做文件上传的时候,想判断用户在IE的file对象中指定的上传的文件在用户机器上是否存在,有什么办法呢?
- javascript 的问题???
- 关于petstore中DAO模式问题,欢迎指教, :)
- hibernate 多对多关系映射问题
- 写xml问题,我现在需要生成一个xml文件,源代码有问题,请指点
- 你写过定时服务吗?
这个做有什么意思?
int a;
public myclass(){
}
void Createdata(){
myclass[] x=new myclass[10];
//这里要加 x[0].a=1;
}
}
x[0]=new myclass();
int a;
public myclass(){
}
void Createdata(){
myclass[] x=new myclass[10];
for(int i =0;i<10;i++){
myclass temp = new myclass()
temp.a = 1;
myclass[i] =temp;
}
}
}
不然你的程序没法执行的。
会出现NullPointException.
否则就会有NullPointException。
这样子只是申请了myclass的10个空间,具体的对象还没有生成
在 x[0].a=1;之前要 x[0] = new myclass();
所以一般在: myclass[] x=new myclass[10];之后紧跟着:
x[0] = new myclass();......x[9] = new myclass();