Kotlin is a new programming language for Android App development and it is discovered by Google.It will be an alternate option in place of Java language for android app development.
4. Introduction
• Kotlin is a statically-typed programming language
• It is jvm targeted language
• It support object oriented programing and
functional programing feature
• It can also can be compiled to JavaScript source
code
• Its primary development is from a team of
JetBrains
5. History…
In July 2011 JetBrains Start Project Kotlin, a new
language for the JVM, which had been under
development for a year.
JetBrains hopes that the new language will
drive IntelliJ IDEA sales.
Kotlin v1.0 was released on February 15, 2016.
In may 2017 Google I/O Declared as the First
class language for android development
6. Features of Kotlin programming language
• Kotlin is open source.
• Full Java Interoperability.
• Kotlin compiles to JVM bytecode or JS.
• Null Safety in Kotlin.
• Kotlin wants you to write less code.
• Higher order function
7. Basic syntax
PACKAGE:-
Package specification should we at the top of the application similar to java
Example-
package Bu.Iet;
import java.util;//import util package
Defining local variables
Example-
var a:Int=12//immediate assignment
var a=123;//type inference
8. Difference Between Kotlin and java
No Semicolons
// Java System.out.println("Hello world!);
// Kotlin println("Hello world!")
10. No Checked Exceptions
• // Java code often looks like this
• Try
• {
• Connection con=DriverManager.getConnection()//this sta throw an
checked exception
• }
catch(SqlException r)
• {
• }
• // Kotlin has no checked exception
11. Type Inference
// Java
Int a = 1;
String b = “sachin";
Program p;
// Kotlin
var a = 1
var b = “sachin"
var p: Program
12. Size of Code
• // Java
• class Person
• {
• String firstName;
Person(String firstName) { this.firstName = firstName;
• }
• }
• // Kotlin class with primary constructor
• class Person(firstName: String)
13. Data Classes
• // Java
• To hold the data we must make simple classes with getter and setter method
in data
• // Kotlin
• In kotlin they provide the concept od data classes to hold the data
• To define an data class in kotlin we use the keyword data before the class
keyword
• data class Student(val name: String,val age: int)