There are three places where the name examPaperId
is referenced. The purpose of each line is as follows:
private Integer examPaperId;
declares that the TaskItemAnswerObject
class contains an instance variable name examPaperId
of type Integer
.
public TaskItemAnswerObject(Integer examPaperId, Integer examPaperAnswerId, Integer status) {
declares a constructor for the TaskItemAnswerObject
object that takes a parameter of type Integer
, named examPaperId
, as its first parameter.
this.examPaperId = examPaperId;
is executed when the constructor mentioned above is called. It takes the incoming parameter named examPaperId
and assigns it to the instance variable named examPaperId
on the instance of the TaskItemAnswerObject
class that is being constructed.
There are other languages that can do all of this in less code. Kotlin, specifically, can do all of this in a single line of code. But Java's syntax is what it is. This is just the way all of this works in Java.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…