1、对象数组的定义一般格式:类名+空格+数组名;数组名=new 类名[ ],这是声明数组,但需要注意的是这里仅仅定义了数组stu的元素,并且每个元素都是一个该类的对象。



2、而这些对象目前都是空对象,因此在使用数组stu中的对象时,应当创建数组所包含的对象,如图所示创建Student对象stu[1].



3、附源代码:
class Student{ int number;}public class E15{ public static void main(String args[ ]){ Student stu[ ] = new Student[10]; for(int i = 0;i<stu.length;i++){ stu[i] = new Student(); stu[i].number = 101+i; } for(int i = 0;i<stu.length;i++){ System.out.println(stu[i].number); } }}


