《Java创建对象类型数组的三种方式》
方法一:
Person[] ps = new Person[5]; ps[0] = new Person("小王", 18, '女', "15619992198"); ps[1] = new Person("小张", 17, '男', "15619992191"); ps[2] = new Person("小马", 15, '男', "15619992192"); ps[3] = new Person("小雨", 16, '女', "15619992196"); ps[4] = new Person("小倩", 19, '女', "15619992199");
方法二:
Person[] ps = new Person[]{ new Person("小王", 18, '女', "15619992198"), new Person("小张", 17, '男', "15619992191"), new Person("小马", 15, '男', "15619992192"), new Person("小雨", 16, '女', "15619992196"), new Person("小倩", 19, '女', "15619992199"), };
方法三:
Person[] ps = { new Person("小王", 18, '女', "15619992198"), new Person("小张", 17, '男', "15619992191"), new Person("小马", 15, '男', "15619992192"), new Person("小雨", 16, '女', "15619992196"), new Person("小倩", 19, '女', "15619992199"), };