this и super
Запазена дума – this
public class Subject {
String name;
double finalGrade;
int hours;
public Subject() {
}
public Subject(String name, int hours) {
this.name = name;
this.hours = hours;
}
public Subject(String name, int hours, double finalGrade) {
this(name, hours); //invokes constructor with only two parameters
this.finalGrade = finalGrade;
}
public String getName(){
return this.name;
}
public Double getFinalGrade(){
return this.finalGrade;
}
public int getHours()
{
return this.hours;
}
public void printSubjectNameAndHours(){
System.out.println("Subject: " + this.getName() + " : " + this.getHours()); //method invoke
}
} Запазена дума – super
Last updated