Let's Learn Kotlin
Let's Learn Kotlin
Kotlin
Hello!
I am Sadman Samee
2
Why learn Kotlin?
Less codes, less crash, nicer
codebase.
3
“
Kotlin is very concise.
Drastically reduce the amount
of boilerplate code.
4
“
Get more with less code =
Decreased dev time and cost.
5
“
That’s why many big companies
are moving to Kotlin.
That means you will be selected in
job boards easily.
6
“
7
“
What if
1. You know Java
2. You have projects in Java
3. Your company works with Java
4. You Want to use Java library
8
One-click Java to Kotlin converter.
3 seconds task and 90-99% code
coverage!
9
Both languages can be used on the same
project.
Convenient
10
Kotlin can use existing Java libraries.
Availability
11
Now, Let’s start to learn
Kotlin….
12
No More Semicolons
13
How to declare a variable
1. val age = 25
2. var name = “samee”
14
Control Flow
val a:Int = 5
val b:Int = 2
var max: Int
if (a > b) {
max = a
} else {
max = b
}
print("Maximum of a or b is " +max)
16
Class and Object
class myClass {
// property (data member)
private var name: String = "sadman samee"
// member function
fun printMe() {
print("Hello "+name)
}
}
fun main(args: Array<String>) {
val obj = myClass() // create obj object of myClass class
obj.printMe()
}
17
Inheritance
open class ABC {
fun think () {
print("Hey!! i am thiking ")
}
}
class BCD: ABC(){ // inheritence happend using default constructor
}
18
Null Check
val a = "Kotlin"
val b: String? = null
println(b?.length)
19
Other things to checkout
1. Extension
2. Data class
3. Default parameter
4. Inline classes
5. Kotlin Anko
6. Static Layout import
7. Lamda expression
8. Type casts
20
Thanks!
Any questions?
21