Skip to content

Commit

Permalink
[Week2][Chap9] super - 부모 참조 (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
arinming committed Jan 16, 2024
1 parent a57f9a1 commit f7039ea
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 김아린/java-basic/src/extends1/super1/Child.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package extends1.super1;

public class Child extends Parent {
public String value = "child";

@Override
public void hello() {
System.out.println("Child.hello");
}

public void call() {
System.out.println("this value = " + this.value); // this 생략 가능
System.out.println("super value = " + super.value);

this.hello(); // this 생략 가능
super.hello();
}
}
9 changes: 9 additions & 0 deletions 김아린/java-basic/src/extends1/super1/Parent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package extends1.super1;

public class Parent {
public String value = "parent";

public void hello() {
System.out.println("Parent.hello");
}
}
8 changes: 8 additions & 0 deletions 김아린/java-basic/src/extends1/super1/Super1Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package extends1.super1;

public class Super1Main {
public static void main(String[] args) {
Child child = new Child();
child.call();
}
}

0 comments on commit f7039ea

Please sign in to comment.