Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions 정다은/03. Anonymous/Anonymous.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package hw_240618;

public class Anonymous {
Vehicle field = new Vehicle() {

@Override
public void run() {
System.out.println("자전거가 달립니다.");
}
};
void method1() {
Vehicle localVar = new Vehicle() {

@Override
public void run() {
System.out.println("승용차가 달립니다.");
}
};
localVar.run();
}

void method2(Vehicle v) {
v.run();
}
}
22 changes: 22 additions & 0 deletions 정다은/03. Anonymous/AnonymousExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package hw_240618;

public class AnonymousExample {

public static void main(String[] args) {
// TODO Auto-generated method stub
Anonymous anony = new Anonymous();
anony.field.run();
anony.method1();
anony.method2(
new Vehicle() {

@Override
public void run() {
System.out.println("트럭이 달립니다.");

}
}
);
}

}
5 changes: 5 additions & 0 deletions 정다은/03. Anonymous/Vehicle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package hw_240618;

public interface Vehicle {
public void run();
}