Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Using Kotlin in Android
Search
Ivan
May 03, 2019
Programming
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Using Kotlin in Android
Kotlin examples for study group in Taiwan Kotlin User Group
Ivan
May 03, 2019
Transcript
12 slides
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
More Decks by Ivan
See All by Ivan
KtRssReader 的奇幻旅程
ivanw
0
170
Kotlin Flow Application and Testing on Android
ivanw
0
360
Kotlin Flow Application and Testing on Android
ivanw
1
490
A Step-by-Step Guide to Kotlin Flow 手把手帶你認識 Kotlin Flow
ivanw
0
290
Coroutines Made Easy
ivanw
1
220
All About KotlinConf 2019
ivanw
0
140
Writing Tests in Kotlin
ivanw
0
380
Other Decks in Programming
See All in Programming
Skills Are the New npm [AAIF Bengaluru, Nov 2026]
shivamsaraswat
0
120
エージェントの管理もエージェントに – herdr-core と自作バックログで作る司令塔 –
nearme_tech
PRO
1
120
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
300
LLM 101
dalinaum
0
540
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
330
はじめてのKubernetesコントリビューション
nasa9084
0
320
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
AIコーディング時代のKotest ユニットテストから APIレベルの仕様固定化テストへ
ooga04
0
330
止まらない比較を止める — 余帰納法で無限ストリームを比べる
tarao
0
210
将来の標準フォーマッター?ktfmtを深堀る
t45k
0
250
Debian JP Projectのサーバー構成
uwabami
1
180
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
230
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
1
320
Scaling GitHub
holman
464
140k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.3k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
360
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
360
The Curious Case for Waylosing
cassininazir
1
630
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Crafting Experiences
bethany
1
460
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
550
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
880