Only the last Object is added to the ArrayList

前端 未结 4 601
悲&欢浪女
悲&欢浪女 2021-01-26 17:21

I created a user defined data type and read data from a file. Here are the codes:

Student Class:

package system.data;

public class Student {

private St         


        
4条回答
  •  北海茫月
    2021-01-26 18:13

    Actually you are always using the same student object.You have to put Student student = new Student(); inside the for loop.

提交回复
热议问题