also JVM based language developed by JetBrains as described before, a company known for the creation of IntelliJ IDEA, a powerful IDE for Java development. In Kotlin everything is an Object.
also JVM based language developed by JetBrains as described before, a company known for the creation of IntelliJ IDEA, a powerful IDE for Java development. In Kotlin everything is an Object. Kotlin is very intuitive and easy to learn for Java developers (give it 10 days trials and you wont regret).
also JVM based language developed by JetBrains as described before, a company known for the creation of IntelliJ IDEA, a powerful IDE for Java development. In Kotlin everything is an Object. Kotlin is very intuitive and easy to learn for Java developers (give it 10 days trials and you wont regret) . Its more expressive & safer
also JVM based language developed by JetBrains as described before, a company known for the creation of IntelliJ IDEA, a powerful IDE for Java development. In Kotlin everything is an Object. Kotlin is very intuitive and easy to learn for Java developers (give it 10 days trials and you wont regret). Its more expressive & safer Its highly interoperable
one of the creators of the programming language ALGOL. Protects against NullPointerException the $1,000,000,000 mistake // compiler error var name: String A non-nullable object can’t be null name = null
one of the creators of the programming language ALGOL. Protects against NullPointerException the $1,000,000,000 mistake // compiler error var name: String A non-nullable object can’t be null name = null // compiler error Specify a nullable object by using “?” var name: String? val length = name.length Kotlin ensures that you don’t mistakenly operate on nullable objects
Making safe calls using “?.” //use ?. to make safe call var name: String? ... val length = name?.length Use ?. to safely access a property/method on a nullable object If name happens to be null, the value of length is 0 (inferred integer). length would be null if it were of another type.
Making use of the “?:” elvis operator //use elvis operator var name: String? val length = name?.length ?: 0 This reads as “if name is not null, use name.length else use 0 Elvis Presley. His hairstyle resembles a Question Mark
Making use of the “!!” assertion operator //use elvis operator var name: String? = null val length = name!!.length This reads as “if name is not null, use name.length else throw a null pointer exception”
Making use of the “!!” assertion operator //use elvis operator var name: String? = null val length = name!!.length This reads as “if name is not null, use name.length else throw a null pointer exception” Be very careful with this operator!!!
simply means that things you create can’t be changed. We need immutability because it: • helps us with thread safety - no synchronization issues • is good for value objects - objects that simply hold value, POJOs etc. • helps debugging threaded applications without losing your hair
private final String name; private final int age; public ImmutableClassJava(String name, int age) { this.name = name; this.age = age; } // no setters public String getName() { return name; } public int getAge() { return age; } } class ImmutableClassJava(val name: String, val age: Int) • Class is final by default • val implies that the parameters are final as well (values can’t be assigned)
here } // function with param fun sampleFuncWithParam(param: String) { // code goes here } A function is declared using the “fun” keyword Method parameters use the “name:Type” notation
here } // function with param fun sampleFuncWithParam(param: String) { // code goes here } // func with param and return type fun capitalize(param: String): String { return param.toUpperCase() } A function is declared using the “fun” keyword Method parameters use the “name:Type” notation Return types are specified after the method definition.
• Object-Oriented and procedural • Safety code • No Semicolon • Expands your skillset • Perfect Support with Android Studio & Gradle • Very easy to get started with Android Development