-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPvsFP.java
More file actions
37 lines (30 loc) · 908 Bytes
/
Copy pathOOPvsFP.java
File metadata and controls
37 lines (30 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package sec01_lambdaexpression.EX01;
interface A {
public abstract void abc();
}
class B implements A {
@Override
public void abc() {
System.out.println("메서드 내용 1");
}
}
public class OOPvsFP {
public static void main(String[] args) {
//#1. 객체지향 프로그래밍 문법 1 (case1)
A a1 = new B();
a1.abc();
//#2. 객체지향 프로그래밍 분법 2 (case2) : 익명이너클래스 사용
A a2 = new A() {
@Override
public void abc() {
System.out.println("메서드 내용 2");
}
};
a2.abc();
//#3. 함수적 프로그래밍 문법(람다식) (case3)
//new A() {
// public void abc까지 중복이 되니까 생략한다.
A a3 = () -> {System.out.println("메서드 내용 3");};
a3.abc();
}
}