0% found this document useful (0 votes)
267 views

Let's Learn Kotlin

Kotlin is a concise language that can drastically reduce boilerplate code, decreasing development time and cost. It is moving to be adopted by many big companies. Kotlin code can be converted from Java easily and both languages can be used together. Kotlin improves on Java by removing semicolons, simplifying variables and control flow, and handling null values safely. Key features include classes, inheritance, extensions, and lambda expressions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
267 views

Let's Learn Kotlin

Kotlin is a concise language that can drastically reduce boilerplate code, decreasing development time and cost. It is moving to be adopted by many big companies. Kotlin code can be converted from Java easily and both languages can be used together. Kotlin improves on Java by removing semicolons, simplifying variables and control flow, and handling null values safely. Key features include classes, inheritance, extensions, and lambda expressions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Let’s Learn

Kotlin
Hello!
I am Sadman Samee

I’m here to talk about kotlin

You can find me at:


fb.me/sameesadman

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”

You can also do but not necessary


3. val age : int = 25
4. var name : String = “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)

val items = listOf(1, 2, 3, 4)


for (i in items)
{
println("values of the array"+i)
}
15
Control Flow
val x:Int = 5
when (x) {
1 -> print("x = = 1")
2 -> print("x = = 2")

else -> { // Note the block


print("x is neither 1 nor 2")
}
}

There’s no Switch statement!

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
}

fun main(args: Array<String>) {


var a = BCD()
a.think()
}

18
Null Check
val a = "Kotlin"
val b: String? = null
println(b?.length)

var a: String = "abc"


a = null // compilation error

var b: String? = "abc"


b = null // ok
print(b)

You should avoid doing this


val l = 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?

You can find me at:


sadmansamee.blog
sadman.tonmoy@gmail.com

21

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy