List<QuestionAnswer> questionAnswers = new ArrayList<QuestionAnswer>();
List<Question> questions = survey.getQuestions();
Iterator<Question> it = questions.iterator();
Question question = new Question();
while(it.hasNext()){
question = it.next();
BeanUtils.copyProperties(question, questionAnswer);
questionAnswers.add(questionAnswer);
List<Question> questions = survey.getQuestions();
Iterator<Question> it = questions.iterator();
Question question = new Question();
while(it.hasNext()){
question = it.next();
QuestionAnswer questionAnswer = new QuestionAnswer();
//必须每次new一个新的对象,否则add后一次添加会覆盖前一次。因为对于List<T>来说,如果T是引用类型,那保存的是引用,如果是值类型,保存的是值本身!
questionAnswers.add(questionAnswer);
}
class Test
{
public static void main(String[] args)
{
Long a = 0L;
System.out.println("a == 0L ? " + (a==0L));
System.out.println("a == 0 ? " + (a==0));
Long b = 0L;
System.out.println("a == b ? " + (a==b));
System.out.println("a equals b ? " + (a.equals(b)));
Long c = new Long(0);
Long d = new Long(0);
System.out.println("c == d ? " + (a==b));
System.out.println("c equals d ? " + (a.equals(b)));
Long e = new Long(3);
Long f = new Long(3);
System.out.println("e == f ? " + (e==f));
}
}