際際滷

際際滷Share a Scribd company logo
2
Most read
4
Most read
??8 ???
???, 2014-05-29
??7, 6, 5, ...
Comparator<Integer> comparator = new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return o2 - o1;
}
};
??8
Comparator<Integer> comparator = (o1, o2) -> o2 - o1;
???(lambda expression)
¢? ??? ????, ??????? ??? ?? ??
? ? ?? ?? ?? ??
o? ?? ?? ???? ??: Ruby, C#, Python,
o? ???? ??? ??? ?? ?
′?? scala: someList.filter(x => x > 0)
¢? ???(Functional) ???? ??? 1?(first-
level class)?
o? ??? ??? ??, ????? ???? ? ??
¢? ??? ??? ???...?
??8? ???
¢? ???(Functional) ?????? ?? ??? ?
???? ??
o? ??? ?????: ?? ???? 1?? ?????
public interface Comparator<T> {
int compare(T o1, T o2);
}
Comparator<Long> comp = (Long o1, Long o2) -> o2 - o1 < 0 ? -1 : 1
???? ??
(Long val1, String val2) -> val1 + val2.length()
???? ?? ?
? ?? ??? ?
public interface Operator<T> {
public T operate(T op1, T op2);
}
public interface Callable<V> {
V call() throws Exception;
}
public interface Runnable {
public void run();
}
public interface Predicate<T> {
boolean test(T t);
}
// ???? ?? ??
Comparator<Long> longComparator =
(Long first, Long second) -> Long.compare(first, second);
// ???? ?? ???? ??, ???? ??
Comparator<Long> longComparator =
(first, second) -> Long.compare(first, second);
// ????? ? ?? ??, ???? ??? ?? ??
Predicate<String> predicate = t -> t.length() > 10;
// ????? ?? ??
Callable<String> callable = () -> "noparam";
// ?? ?? ?? ??
Runnable runnable = () -> System.out.println("no return");
// ?? ??? ??? ??, return? ???? ?? ?? ??
Operator<Integer> plusSquareOp = (op1, op2) -> {
int result = op1 + op2;
return result * result;
};
???? ?? ??
int multiple = 10;
Operator<Integer> operator = (x) -> x * multiple;
int result = operation( operator );
?? ??(free variable):
???? ????? ? ???? ???? ?? ??
¢? ??? ????? ???? ????? ?? ??? ? ??
¢? ?? ??? ?? ?? ??? ??? final? ???? ???, ????
?? ?? ??? ?? ??? ??? ????? ??? ???? ??
? ?? ?? ??? ??? ?????
java.util.function ???? ??? ??
? ??? ? ?? ??? ????? ?
??
public interface Function<T, R> {
R apply(T t);
}
public interface Predicate<T> {
boolean test(T t);
}
public interface BiFunction<T, U, R> {
R apply(T t, U u);
}
public interface Supplier<T> {
T get();
}
public interface Consumer<T> {
void accept(T t);
}
??? ????? ??
¢? @FuntionalInterface ??
o? @FuntionalInterface? ?? ?????? ?? ????
? ? ?? ??? ??? ?? ??!
@FunctionalInterface
public interface Operator<T> {
public T operate(T op1, T op2);
}
??? ????
?? ??
public class SomeView
implements OnClickListener {
private void init() {
myBtn.setOnClickListener(this);
youBtn.setOnClickListener(this);
}
@Override
public void onClick(ClickEvent e) {
´
if (e.getSource() == myBtn) {
...
}
}
}
??? ???? ??
public class SomeView {
private void init() {
myBtn.setOnClickListener(this::onMyBtnClick);
youBtn.setOnClickListener(this::onYouBtnClick);
}
private void onMyBtnClick(ClickEvent e) {
...
}
private void onYouBtnClick(ClickEvent e) {
...
}
}
??? ???? ??
¢? ???::?????
o? someOperation( Op::square );
′?? someOperation( (x, y) -> Op.square(x, y) );
¢? ??::???????
o? someOperation( obj::square );
′?? someOperation( (x, y) -> obj.square(x, y) );
o? someOperation( this::square );
o? someOperation( super::square );
¢? ???::???????
o? someOperation( XClass::double )
′?? someOperation( (x, y) -> x.double(y) )
?????? ??
¢? ??? ???(default method)
o? ????? ???? ??? ?? ? ??
¢? ?? ???
o? ?????? ?? ???? ?? ? ??
??? ???
public interface Collection<E> extends Iterable<E> {
Iterator<E> iterator();
default boolean removeIf(Predicate<? super E> filter) {
Objects.requireNonNull(filter);
boolean removed = false;
final Iterator<E> each = iterator();
while (each.hasNext()) {
if (filter.test(each.next())) {
each.remove();
removed = true;
}
}
return removed;
}
LinkedList<Long> list = ´.;
list.removeIf((e) -> e > 10L);
??? ???? ?? ??
class Team {
public int version() {
return 0;
}
}
interface Verion {
default int version() {
return -1;
}
}
interface Lockable {
default int version() {
return 1;
}
}
class ExtTeam
extends Team
implements Version {
}
?? ???? ???? ??
- ExtTeam ??? getVersion()?
Team ???? getVersion() ??
class Job implements
Version, Lockable {
@Override
public int version() {
return Version.super.getName()
}
}
???? ??????? ?? ????
? ?? ??? ? ? ??? ??? ??
?? ???,
?? ???? ???? ??? ?
Optional? ???? ??
¢? java.util.Optional???
o? ?? ??? ?? ?? ??? ???? ?? ???
o? ??? ?
′?? Optional<Long> value = someMethod();
if (value.isPresent()) {
Long val = value.get();
}
o? map, filter ?? ???(higher order) ??? ??
′?? public<U> Optional<U> map(Function<? super T, ? extends U> mapper)
′?? public Optional<T> filter(Predicate<? super T> predicate)
′?? public<U> Optional<U> flatMap(Function<? super T, Optional<U>> mapper)
Optional? ???? ??
¢? Optional? ??? ??? ??
Optional<Member> mem = findMemberById(1L);
Coord result = mem.map(Member::getAddress)
.map(address -> address.getZipCode())
.map(zipCode -> findCoord(zipCode))
.orElse(null);
Member mem = findMemberById(1L);
Coord result = null;
if (mem != null) {
if (mem.getAddress() != null) {
String zipCode = mem.getAddress().getZipCode();
if (zipCode != null) result = findCoord(zipCode);
}
}
??
¢? ??8 ???API: ??? ????? ??
o? filter(Predicate)
o? map(Function)
o? sorted(Comparator)
o? forEach(Consumer)
o? reduce(identity, BinaryOperator)
o? ´

More Related Content

What's hot (20)

PDF
????? ??????(Feat. gcp) - ??????(GCP) ?? ??
Seongyun Byeon
?
PDF
ト?メインl強譜柴壅秘壇
Yukei Wachi
?
PDF
??? TDD 101
?? ?
?
PDF
??? Front-End ????? ??????
JinKwon Lee
?
PDF
??? ???? ??? ?(Shift left testing)
SangIn Choung
?
PDF
View customize plugin for RedmineのB初 (2019定井)
onozaty
?
PDF
DDD ???? (?? Final ??)
beom kyun choi
?
PDF
JavaScript GIS ライブラリ turf.js 秘T
Takahiro Kamada
?
PPTX
Windowsサ`ビスも.NET Coreで恬ろう
keitasudo1
?
PDF
01.?????????
Hankyo
?
PDF
Data Science. Intro
Seongyun Byeon
?
PPTX
Cordova を聞って云櫃派毛奪魯ぅ屮螢奪疋▲廛裼_kをやってみた
Shin Ogata
?
PPTX
? ?? ??? ??? ??? ?? ?????. (Deep Learning for Natural Language Processing)
WON JOON YOO
?
PDF
AWS クラウドでBするスマホアプリ バックエンド
kaki_k
?
PDF
Linked Open Data(LOD)を聞うと^うれしい ̄3つの尖喇
Kouji Kozaki
?
PDF
‐de:code 2020/ Azure Bot Services を聞って Teams bot を_kする
晩云マイクロソフト幄塀氏芙
?
PPTX
[Foss4 g2013 korea]postgis? geoserver? ??? ??? ????? ?? ??? ??? ?? ??
BJ Jang
?
PDF
??? ??? ?????
sangyong lee
?
PPTX
晦庄厩艶2禽ライクなオ`プンソ`スソフトウェアの蝕k
yuki540
?
PDF
[236] ????????????????????????? ????????
NAVER D2
?
????? ??????(Feat. gcp) - ??????(GCP) ?? ??
Seongyun Byeon
?
ト?メインl強譜柴壅秘壇
Yukei Wachi
?
??? TDD 101
?? ?
?
??? Front-End ????? ??????
JinKwon Lee
?
??? ???? ??? ?(Shift left testing)
SangIn Choung
?
View customize plugin for RedmineのB初 (2019定井)
onozaty
?
DDD ???? (?? Final ??)
beom kyun choi
?
JavaScript GIS ライブラリ turf.js 秘T
Takahiro Kamada
?
Windowsサ`ビスも.NET Coreで恬ろう
keitasudo1
?
01.?????????
Hankyo
?
Data Science. Intro
Seongyun Byeon
?
Cordova を聞って云櫃派毛奪魯ぅ屮螢奪疋▲廛裼_kをやってみた
Shin Ogata
?
? ?? ??? ??? ??? ?? ?????. (Deep Learning for Natural Language Processing)
WON JOON YOO
?
AWS クラウドでBするスマホアプリ バックエンド
kaki_k
?
Linked Open Data(LOD)を聞うと^うれしい ̄3つの尖喇
Kouji Kozaki
?
‐de:code 2020/ Azure Bot Services を聞って Teams bot を_kする
晩云マイクロソフト幄塀氏芙
?
[Foss4 g2013 korea]postgis? geoserver? ??? ??? ????? ?? ??? ??? ?? ??
BJ Jang
?
??? ??? ?????
sangyong lee
?
晦庄厩艶2禽ライクなオ`プンソ`スソフトウェアの蝕k
yuki540
?
[236] ????????????????????????? ????????
NAVER D2
?

Viewers also liked (13)

PDF
?? Ip ?? ?? ???
beom kyun choi
?
PDF
TDD ?????????? @ ?????
beom kyun choi
?
PDF
java 8 ??? ??? ?? ??
Sungchul Park
?
PDF
keras ?? ????(intro)
beom kyun choi
?
PDF
Tdd live spring camp 2013
beom kyun choi
?
PDF
Okjsp 13?? ????: ?? ????? Test
beom kyun choi
?
PDF
Spring Boot ??
beom kyun choi
?
PDF
????? ???? ??? ???? ??? (???)
Yongho Ha
?
PDF
?????4. ?????? ??????? ?????? ?????????? ???????????
Jay JH Park
?
PDF
?????3. geth ???????????? ?????? ??? ??????????? ???????
Jay JH Park
?
PDF
?????5. web3.js? Node.js ? ??? dApp ??
Jay JH Park
?
PDF
?????1. block chain as a platform
Jay JH Park
?
PDF
?????2. ????????? ????? ???????????? ???????
Jay JH Park
?
?? Ip ?? ?? ???
beom kyun choi
?
TDD ?????????? @ ?????
beom kyun choi
?
java 8 ??? ??? ?? ??
Sungchul Park
?
keras ?? ????(intro)
beom kyun choi
?
Tdd live spring camp 2013
beom kyun choi
?
Okjsp 13?? ????: ?? ????? Test
beom kyun choi
?
Spring Boot ??
beom kyun choi
?
????? ???? ??? ???? ??? (???)
Yongho Ha
?
?????4. ?????? ??????? ?????? ?????????? ???????????
Jay JH Park
?
?????3. geth ???????????? ?????? ??? ??????????? ???????
Jay JH Park
?
?????5. web3.js? Node.js ? ??? dApp ??
Jay JH Park
?
?????1. block chain as a platform
Jay JH Park
?
?????2. ????????? ????? ???????????? ???????
Jay JH Park
?
Ad

Similar to ????8 ???????? ???? (20)

PPTX
Java8 ??
Jong Woo Rhee
?
PDF
???? ???????? ????8 ???????? ????????
daewon jeong
?
PDF
??? ?? 2?
HyeonSeok Choi
?
PPTX
??? ??? Chap.14 ??? Lambda expression(java)(KOR)
MIN SEOK KOO
?
PPTX
[???] The C++ Programming Language 11? ??? ????
??
?
PDF
Java8 - Oracle Korea Magazine
Jay Lee
?
PPTX
Functional programming
ssuserdcfefa
?
PDF
SpringCamp 2013 : About Jdk8
Sangmin Lee
?
PPTX
Gpg gems1 1.3
david nc
?
PPTX
?? 8 ??
HeeChang Lee
?
PDF
Java jungsuk3 ch14_lambda_stream
? ??
?
PPTX
??????? ????? ????????
Yong Joon Moon
?
PDF
20220716_??????????? ????? POP
Chiwon Song
?
PPTX
Startup JavaScript 6 - ??, ???, ???
Circulus
?
PDF
2014.07.26 KSUG? ???? ???? ???? ??? - ??? ???????? ????8 ???????? (???)
JiandSon
?
PPTX
??????? ??? ?? C++
KWANGIL KIM
?
PDF
5 swift ?????????
Changwon National University
?
PDF
[C++ Korea 2nd Seminar] C++17 Key Features Summary
Chris Ohk
?
PDF
Start IoT with JavaScript - 6.??
Park Jonggun
?
PPTX
About Visual C++ 10
?? ?
?
Java8 ??
Jong Woo Rhee
?
???? ???????? ????8 ???????? ????????
daewon jeong
?
??? ?? 2?
HyeonSeok Choi
?
??? ??? Chap.14 ??? Lambda expression(java)(KOR)
MIN SEOK KOO
?
[???] The C++ Programming Language 11? ??? ????
??
?
Java8 - Oracle Korea Magazine
Jay Lee
?
Functional programming
ssuserdcfefa
?
SpringCamp 2013 : About Jdk8
Sangmin Lee
?
Gpg gems1 1.3
david nc
?
?? 8 ??
HeeChang Lee
?
Java jungsuk3 ch14_lambda_stream
? ??
?
??????? ????? ????????
Yong Joon Moon
?
20220716_??????????? ????? POP
Chiwon Song
?
Startup JavaScript 6 - ??, ???, ???
Circulus
?
2014.07.26 KSUG? ???? ???? ???? ??? - ??? ???????? ????8 ???????? (???)
JiandSon
?
??????? ??? ?? C++
KWANGIL KIM
?
[C++ Korea 2nd Seminar] C++17 Key Features Summary
Chris Ohk
?
Start IoT with JavaScript - 6.??
Park Jonggun
?
About Visual C++ 10
?? ?
?
Ad

More from beom kyun choi (20)

PDF
?? ? ???? ?? ?? Vue.js ??
beom kyun choi
?
PDF
DDD? ??? ???
beom kyun choi
?
PDF
DDD ?? ???
beom kyun choi
?
PDF
Tensorflow regression ????? ??
beom kyun choi
?
PDF
Ddd start ????? ????????&ksug
beom kyun choi
?
PDF
MVP ?? ??
beom kyun choi
?
PPTX
??? ?? ??
beom kyun choi
?
PDF
????? KSUG 20151128
beom kyun choi
?
PDF
Event source ?????? ????? ?????
beom kyun choi
?
PDF
???????? ?????? ??
beom kyun choi
?
PDF
ALS WS? ?? ???? ??
beom kyun choi
?
PDF
Ji ?? ?? (???????)
beom kyun choi
?
PDF
?????? ????? ????
beom kyun choi
?
PDF
??????? ???????? ???? ????
beom kyun choi
?
PDF
Zookeeper ??
beom kyun choi
?
PDF
??2 YARN ?? ??
beom kyun choi
?
PDF
???? ???? (PCA, SVD, NMF)
beom kyun choi
?
PDF
?? ?? ???? JCO ???? 14?
beom kyun choi
?
PDF
Storm ????
beom kyun choi
?
PDF
Hive ?? ?? ??
beom kyun choi
?
?? ? ???? ?? ?? Vue.js ??
beom kyun choi
?
DDD? ??? ???
beom kyun choi
?
DDD ?? ???
beom kyun choi
?
Tensorflow regression ????? ??
beom kyun choi
?
Ddd start ????? ????????&ksug
beom kyun choi
?
MVP ?? ??
beom kyun choi
?
??? ?? ??
beom kyun choi
?
????? KSUG 20151128
beom kyun choi
?
Event source ?????? ????? ?????
beom kyun choi
?
???????? ?????? ??
beom kyun choi
?
ALS WS? ?? ???? ??
beom kyun choi
?
Ji ?? ?? (???????)
beom kyun choi
?
?????? ????? ????
beom kyun choi
?
??????? ???????? ???? ????
beom kyun choi
?
Zookeeper ??
beom kyun choi
?
??2 YARN ?? ??
beom kyun choi
?
???? ???? (PCA, SVD, NMF)
beom kyun choi
?
?? ?? ???? JCO ???? 14?
beom kyun choi
?
Storm ????
beom kyun choi
?
Hive ?? ?? ??
beom kyun choi
?

????8 ???????? ????

  • 2. ??7, 6, 5, ... Comparator<Integer> comparator = new Comparator<Integer>() { @Override public int compare(Integer o1, Integer o2) { return o2 - o1; } };
  • 4. ???(lambda expression) ¢? ??? ????, ??????? ??? ?? ?? ? ? ?? ?? ?? ?? o? ?? ?? ???? ??: Ruby, C#, Python, o? ???? ??? ??? ?? ? ′?? scala: someList.filter(x => x > 0) ¢? ???(Functional) ???? ??? 1?(first- level class)? o? ??? ??? ??, ????? ???? ? ?? ¢? ??? ??? ???...?
  • 5. ??8? ??? ¢? ???(Functional) ?????? ?? ??? ? ???? ?? o? ??? ?????: ?? ???? 1?? ????? public interface Comparator<T> { int compare(T o1, T o2); } Comparator<Long> comp = (Long o1, Long o2) -> o2 - o1 < 0 ? -1 : 1
  • 6. ???? ?? (Long val1, String val2) -> val1 + val2.length() ???? ?? ?
  • 7. ? ?? ??? ? public interface Operator<T> { public T operate(T op1, T op2); } public interface Callable<V> { V call() throws Exception; } public interface Runnable { public void run(); } public interface Predicate<T> { boolean test(T t); } // ???? ?? ?? Comparator<Long> longComparator = (Long first, Long second) -> Long.compare(first, second); // ???? ?? ???? ??, ???? ?? Comparator<Long> longComparator = (first, second) -> Long.compare(first, second); // ????? ? ?? ??, ???? ??? ?? ?? Predicate<String> predicate = t -> t.length() > 10; // ????? ?? ?? Callable<String> callable = () -> "noparam"; // ?? ?? ?? ?? Runnable runnable = () -> System.out.println("no return"); // ?? ??? ??? ??, return? ???? ?? ?? ?? Operator<Integer> plusSquareOp = (op1, op2) -> { int result = op1 + op2; return result * result; };
  • 8. ???? ?? ?? int multiple = 10; Operator<Integer> operator = (x) -> x * multiple; int result = operation( operator ); ?? ??(free variable): ???? ????? ? ???? ???? ?? ?? ¢? ??? ????? ???? ????? ?? ??? ? ?? ¢? ?? ??? ?? ?? ??? ??? final? ???? ???, ???? ?? ?? ??? ?? ??? ??? ????? ??? ???? ??
  • 9. ? ?? ?? ??? ??? ????? java.util.function ???? ??? ?? ? ??? ? ?? ??? ????? ? ?? public interface Function<T, R> { R apply(T t); } public interface Predicate<T> { boolean test(T t); } public interface BiFunction<T, U, R> { R apply(T t, U u); } public interface Supplier<T> { T get(); } public interface Consumer<T> { void accept(T t); }
  • 10. ??? ????? ?? ¢? @FuntionalInterface ?? o? @FuntionalInterface? ?? ?????? ?? ???? ? ? ?? ??? ??? ?? ??! @FunctionalInterface public interface Operator<T> { public T operate(T op1, T op2); }
  • 11. ??? ???? ?? ?? public class SomeView implements OnClickListener { private void init() { myBtn.setOnClickListener(this); youBtn.setOnClickListener(this); } @Override public void onClick(ClickEvent e) { ´ if (e.getSource() == myBtn) { ... } } } ??? ???? ?? public class SomeView { private void init() { myBtn.setOnClickListener(this::onMyBtnClick); youBtn.setOnClickListener(this::onYouBtnClick); } private void onMyBtnClick(ClickEvent e) { ... } private void onYouBtnClick(ClickEvent e) { ... } }
  • 12. ??? ???? ?? ¢? ???::????? o? someOperation( Op::square ); ′?? someOperation( (x, y) -> Op.square(x, y) ); ¢? ??::??????? o? someOperation( obj::square ); ′?? someOperation( (x, y) -> obj.square(x, y) ); o? someOperation( this::square ); o? someOperation( super::square ); ¢? ???::??????? o? someOperation( XClass::double ) ′?? someOperation( (x, y) -> x.double(y) )
  • 13. ?????? ?? ¢? ??? ???(default method) o? ????? ???? ??? ?? ? ?? ¢? ?? ??? o? ?????? ?? ???? ?? ? ??
  • 14. ??? ??? public interface Collection<E> extends Iterable<E> { Iterator<E> iterator(); default boolean removeIf(Predicate<? super E> filter) { Objects.requireNonNull(filter); boolean removed = false; final Iterator<E> each = iterator(); while (each.hasNext()) { if (filter.test(each.next())) { each.remove(); removed = true; } } return removed; } LinkedList<Long> list = ´.; list.removeIf((e) -> e > 10L);
  • 15. ??? ???? ?? ?? class Team { public int version() { return 0; } } interface Verion { default int version() { return -1; } } interface Lockable { default int version() { return 1; } } class ExtTeam extends Team implements Version { } ?? ???? ???? ?? - ExtTeam ??? getVersion()? Team ???? getVersion() ?? class Job implements Version, Lockable { @Override public int version() { return Version.super.getName() } } ???? ??????? ?? ???? ? ?? ??? ? ? ??? ??? ?? ?? ???, ?? ???? ???? ??? ?
  • 16. Optional? ???? ?? ¢? java.util.Optional??? o? ?? ??? ?? ?? ??? ???? ?? ??? o? ??? ? ′?? Optional<Long> value = someMethod(); if (value.isPresent()) { Long val = value.get(); } o? map, filter ?? ???(higher order) ??? ?? ′?? public<U> Optional<U> map(Function<? super T, ? extends U> mapper) ′?? public Optional<T> filter(Predicate<? super T> predicate) ′?? public<U> Optional<U> flatMap(Function<? super T, Optional<U>> mapper)
  • 17. Optional? ???? ?? ¢? Optional? ??? ??? ?? Optional<Member> mem = findMemberById(1L); Coord result = mem.map(Member::getAddress) .map(address -> address.getZipCode()) .map(zipCode -> findCoord(zipCode)) .orElse(null); Member mem = findMemberById(1L); Coord result = null; if (mem != null) { if (mem.getAddress() != null) { String zipCode = mem.getAddress().getZipCode(); if (zipCode != null) result = findCoord(zipCode); } }
  • 18. ?? ¢? ??8 ???API: ??? ????? ?? o? filter(Predicate) o? map(Function) o? sorted(Comparator) o? forEach(Consumer) o? reduce(identity, BinaryOperator) o? ´