Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Using Kotlin in Android
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Ivan
May 03, 2019
Programming
0
110
Using Kotlin in Android
Kotlin examples for study group in Taiwan Kotlin User Group
Ivan
May 03, 2019
Tweet
Share
More Decks by Ivan
See All by Ivan
KtRssReader 的奇幻旅程
ivanw
0
94
Kotlin Flow Application and Testing on Android
ivanw
0
320
Kotlin Flow Application and Testing on Android
ivanw
1
450
A Step-by-Step Guide to Kotlin Flow 手把手帶你認識 Kotlin Flow
ivanw
0
210
Coroutines Made Easy
ivanw
1
190
All About KotlinConf 2019
ivanw
0
130
Writing Tests in Kotlin
ivanw
0
340
Other Decks in Programming
See All in Programming
The Ralph Wiggum Loop: First Principles of Autonomous Development
sembayui
0
3.7k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
350
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
410
CopilotKit + AG-UIを学ぶ
nearme_tech
PRO
1
110
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
190
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
1.2k
CSC307 Lecture 14
javiergs
PRO
0
440
24時間止められないシステムを守る-医療ITにおけるランサムウェア対策の実際
koukimiura
2
180
CSC307 Lecture 10
javiergs
PRO
1
690
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
120
文字コードの話
qnighy
43
16k
Railsの気持ちを考えながらコントローラとビューを整頓する/tidying-rails-controllers-and-views-as-rails-think
moro
4
360
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
89
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Bash Introduction
62gerente
615
210k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.3k
Leo the Paperboy
mayatellez
4
1.5k
What does AI have to do with Human Rights?
axbom
PRO
0
2k
The Pragmatic Product Professional
lauravandoore
37
7.2k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
300
Building a Scalable Design System with Sketch
lauravandoore
463
34k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
230
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Transcript
Using Kotlin in Android Ivan W.
Outline • Null Safety • Data Class • Default Argument
/ Implementation 2
Null Safety • Eliminate the danger of null references from
code • Nullable types and Non-Null Types var a: String = "abc" a = null // compilation error var b: String? = "abc" b = null // ok 3 Nullable types Non-Null types
Example 1 4 Bundle args = getArguments(); if (args !=
null) { Bundle data = args.getBundle(KEY_DATA); if (data != null) { Log.d(TAG, data.getString(KEY_NAME)); } } Java
Example 1 5 Bundle args = getArguments(); if (args !=
null) { Bundle data = args.getBundle(KEY_DATA); if (data != null) { Log.d(TAG, data.getString(KEY_NAME)); } } Log.d(TAG, arguments?.getBundle(KEY_DATA)?.getString(KEY_NAME)) Java Kotlin
Data Class • It automatically generates ◦ equals() / hashCode()
◦ getters and setters ◦ toString() ◦ copy()
Example 2 7 Java Kotlin See example See example
Default Argument / Implementation 8 • Java overloads can be
replaced with one function in Kotlin
Example 3 9 private void sendInfo(String content, long Time, String
tag) { /* ... */ } private void sendInfo(String content, long Time) { /* ... */ } private void sendInfo(String content, String tag) { /* ... */ } private void sendInfo(String content) { /* ... */ } Java
Example 3 10 private fun sendInfo( content: String, time: Long
= Date().time, tag: String = TAG ) { … } sendInfo("content", time = Date().time) Kotlin
Example 4 11 Java Kotlin See example See example
Thank you! 12