Skip to Content
자바에서 코틀린으로
book

자바에서 코틀린으로

by 덩컨 맥그레거, 냇 프라이스, 오현석
November 2022
Beginner to intermediate
544 pages
12h 39m
Korean
Hanbit Media, Inc.
Content preview from 자바에서 코틀린으로
404
자바에서 코틀린으로
register
메서드의
throw
절을 보라. 이 부분은
register
메서드가 명시적인 예외 목록에
따라 실패할 수 있다는 사실을 알려 주며, 추가로
customers
.
add
DuplicateException
함께 실패할 수 있다는 사실도 알려 준다. 다음은
Customers
인터페이스다.
예제
19.3
[
errors
.
0
:
src
/
main
/
java
/
travelator
/
Customers
.
java
]
public interface Customers {
Customer add(String name, String email) throws DuplicateException;
Optional<Customer> find(String id);
}
마지막으로
Customer
도 값 타입이다. 다음은 이 타입을 코틀린으로 변환한 모습이다.
예제
19.4
[
errors
.
1
:
src
/
main
/
java
/
travelator
/
Customer
.
kt
]
data class Customer(
val id: String,
val name: String,
val email: String
)
지금 본 각 코드는 저자들이 작성한 전형적인 자바 코드 스타일로 되어있다. 이 코드는 체크 예
외인
ExcludedException
이나
DuplicateException ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

고성능 파이썬(2판)

고성능 파이썬(2판)

오현석, 미샤 고렐릭, 이안 오스발트
러닝 타입스크립트

러닝 타입스크립트

조시 골드버그
실리콘밸리 리더십

실리콘밸리 리더십

김정혜, 마이클 롭

Publisher Resources

ISBN: 9791169210447