Skip to content

Commit c9eae6f

Browse files
authored
Merge pull request #121 from hp113/update-readme-aggregation
Fix private field access error in Aggregation example by adding getter method
2 parents 04dbf98 + 93438ff commit c9eae6f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

oop/java/aggregation/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class Professor {
3232
this.subject = subject;
3333
}
3434

35+
public String getName(){
36+
return name;
37+
}
38+
3539
public void teach() {
3640
System.out.println(name + " is teaching " + subject);
3741
}
@@ -53,7 +57,7 @@ class University {
5357
public void showProfessors() {
5458
System.out.println("Professors at " + universityName + ":");
5559
for (Professor professor : professors) {
56-
System.out.println(" - " + professor.name);
60+
System.out.println(" - " + professor.getName());
5761
}
5862
}
5963
}

0 commit comments

Comments
 (0)