一个对象类
public class Study {
String name;
}
基于对象的数组的赋值与遍历
Study[] stu;
stu = new Study[6];
String[] name = {"111","222","333","444","555","666"};
//利用数组和for循环给对象数组赋值
for(int x = 0; x<stu.length;x++)
{
Study person = new Study();
if(x<name.length)
person.name = name[x];
stu[x] = person;
}
//遍历对象数组,读出数据
for (Study per : stu )
{
System.out.println(per.name);
}
by 2019年10月24日