日期:2014-05-20  浏览次数:20752 次

java 循环数组,并加到对象的属性里
比如:String [] a=new String[] {"1","2","3","4","5","6",“7”};String [] b=new String[] {"8","9","10","11","12","13",“14”};String [] c=new String[] {"15","16","17","18","19","20",“21”};String [] d=new String[] {"22","23","24","25",“26”,"27","28",}....,Student student = new Student ();
如何取到全部数组的第一个,第二个元素。。。添加到student对象的属性 里;即把1,8,15,22和2,9,16,23。。添加到student 里对象的属性,数组里的元素,为对象属性的值

------解决方案--------------------
very easy 思考几分钟就搞定了,要自己动脑才会越来越聪明哦,亲!
------解决方案--------------------
弄成二维数组,循环操作就ok了。
------解决方案--------------------
如果数组是对齐的,确实不难,比方说
Student[] list = new Student[a.length];
for (int i=0; i<a.length; i++){
list[i] = new Student();
list[i].setA( a[i]);
list[i].setB( b[i]);
...
}