package dome;
public class Person {
public int age;
public String name;
public Person(int age,String name){
this.age=age;
this.name=name;
}
}``
package dome;
/**2021-4-1
* 对象数组
* RJ
*/
public class Text {
public static void main(String[] args) {
Person[]person={new Person(22,"韩冰"),new Person(23,"刘颖"),new Person(24,"昊天")};
for(int i = 0;i< person.length;i++){
System.out.println("age属性等于"+person[i].age+","+"name属性等于"+person[i].name);
}
}
}
age属性等于22,name属性等于韩冰
age属性等于23,name属性等于刘颖
age属性等于24,name属性等于昊天
进程已结束,退出代码为 0