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
Android Entwicklung mit Kotlin
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Volkmar Vogel
January 26, 2017
Programming
38
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Android Entwicklung mit Kotlin
Volkmar Vogel
January 26, 2017
Other Decks in Programming
See All in Programming
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
110
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
1k
The Rails Doctrine Decade
koic
2
590
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
180
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
SREの越境 / SRE Collaboration
y0hgi
2
310
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
500
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
150
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
210
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
590
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
940
How GitHub (no longer) Works
holman
316
150k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
59k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
730
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Become a Pro
speakerdeck
PRO
31
6.3k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
800
Odyssey Design
rkendrick25
PRO
2
870
Transcript
Android Entwicklung mit Kotlin Volkmar Vogel
• Entwickler: JetBrains • Version 1.0 am 15 Februar 2016
• Statisch typisierte Programmiersprache • Kompiliert zu Java 6 Bytecode
Syntax Crashkurs
int sum(int a, int b) { return a + b;
}
fun sum(a: Int, b: Int): Int { return a +
b }
fun sum(a: Int, b: Int) = a + b
final String immutable = "Hallo World”; String mutable =
"Hallo World";
val immutable = "Hallo World" var mutable = "Hallo World"
public class MyClass { private final String text;
public MyClass(String text) { this.text = text; } public String getText() { return text; } }
class MyClass(val text: String)
public class DataClass { private final String nonNull; private
final String nullable; public DataClass(@NonNull String nonNull, @Nullable String nullable) { this.nonNull = nonNull; this.nullable = nullable; } }
data class DataClass(val nonNull: String, val nullable: String?)
Null Safety
I call it my billion-dollar mistake. It was the invention
of the null reference in 1965. […] This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years. Sir Tony Hoare (Quelle: Wikipedia)
None
var nonNull: String = "Hallo World" nonNull = null //
kompiliert nicht var nullable: String? = "Hallo World" nullable = null
data class Person(val name: String?, val isMale: Boolean) val
name = if (person.name == null) "Volkmar" else person.name
data class Person(val name: String?, val isMale: Boolean) val
name = person.name ?: "Volkmar"
?:)
data class Person(val name: String?, val isMale: Boolean)
data class Person(val name: String?, val isMale: Boolean) var
personList: List<Person?>? = null
data class Person(val name: String?, val isMale: Boolean) var
personList: List<Person?>? = null
data class Person(val name: String?, val isMale: Boolean) var
personList: List<Person?>? = null personList ?.filterNotNull()
data class Person(val name: String?, val isMale: Boolean) var
personList: List<Person?>? = null personList ?.filterNotNull() ?.filter { it.name != null }
data class Person(val name: String?, val isMale: Boolean) var
personList: List<Person?>? = null personList ?.filterNotNull() ?.filter { it.name != null } ?.map { "${if (it.isMale) "Mr." else "Mrs."} ${it.name}" }
data class Person(val name: String?, val isMale: Boolean) var
personList: List<Person?>? = null personList ?.filterNotNull() ?.filter { it.name != null } ?.map { "${if (it.isMale) "Mr." else "Mrs."} ${it.name}" } ?.forEach(::println)
Extension Functions
public class ContextUtils { public static void toast(Context ctx, String
s) { Toast.makeText(ctx, s, Toast.LENGTH_SHORT).show(); } }
fun Context.toast(s: String, duration: Int = Toast.LENGTH_LONG) = Toast.makeText(this,
s, duration).show()
fun Context.toast(s: String, duration: Int = Toast.LENGTH_LONG) = Toast.makeText(this,
s, duration).show()
None
Lambdas
view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) {
// do stuff } });
view.setOnClickListener { // do stuff }
val func1: () -> Unit = { /* do stuff
*/ } val func2: (Int) -> String = Int::toString val func3: (View) -> Unit = { it.visibility = View.GONE } view.setOnClickListener(func3)
//Collections.kt public inline fun <T> Iterable<T>.forEach(action: (T) -> Unit): Unit
{ for (element in this) action(element) } public inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> { return mapTo(ArrayList<R>(collectionSizeOrDefault(10)), transform) }
Demo!
Fragen?