For Developing an android application, android developers are using JAVA language but in present Android developers also choose a new option Kotlin Programming language.
Recommended Post: How to Create Virtual Device in Android Studio
Kotlin – Kotlin is a statically-typed programming language that runs on the Java virtual machine and also can be compiled with JavaScript source code or use the LLVM compiler infrastructure. Its primary development is from a team of JetBrains programmers based in Saint Petersburg, Russia. While the syntax is not compatible with Java, Kotlin is designed to interoperate with Java code and is reliant on Java code from the existing Java Class Library, such as the collections framework.
As of Android Studio 3.0 (Beta version) Kotlin is a fully supported programming language on Android and lets the user choose between targeting Java 6- or Java 8-compatible bytecode.
Designed By – Kotlin Programming Language is designed by Jetbrains.
Developer – JetBrains and open source contributors
Filename Extensions – is .kt , .kts
Platform – Outputs Java virtual machine bytecode and JavaScript source code
Operating System – Any supporting JVM (Java Virtual Machine) or JavaScript interpreter
License – Apache 2
Explain it.
object MyObject { val demoName: String = “weblizar” }
2. Safe – Avoid entire classes of errors such as null pointer exceptions.
// NullPointerExceptions var output: String output = null // Compilation error //Kotlin protects you from mistakenly operating on nullable types val demo: String? = null // Nullable type println(demo.length()) // Compilation error //And if you check a type is right, the compiler will auto-cast it for you fun countSum(obj: Any) { if (obj is Invoice) obj.countSum() }
3. Interoperable – Leverage existing libraries for the JVM, Android, and the browser.
//Use any existing library on the JVM, as there’s 100% compatibility, including SAM support. import io.reactivex.Flowable import io.reactivex.schedulers.Schedulers Flowable .fromCallable { Thread.sleep(1000) // imitate expensive computation "Done" } .subscribeOn(Schedulers.io()) .observeOn(Schedulers.single()) .subscribe(::println, Throwable::printStackTrace) //Target either the JVM or JavaScript. Write code in Kotlin and decide where you want to deploy to import kotlin.browser.window fun onLoad() { window.document.body!!.innerHTML += " Hello, Kotlin!" }
4. Tool-Friendly – Choose any Java IDE or build from the command line.
// A language needs tooling and at JetBrains, it's what we do best!Refrence From
Concise, simple and very easy to read (and write)
Basic Program in Kotlin
Programme Name – prg_1_HelloWorld.kt
//Hello World Program in Kotlin package weblizar.prg_1_HelloWorld fun main(args: Array) { println("Hello, world!") }
Output
Hello, world!
Explore Kotlin Code using.
1.IntelliJ IDEA
2.Android Studio
3.Eclipse
4.Compiler
In Brief –
1. IntelliJ Idea – Bundled with Community Edition or IntelliJ IDEA Ultimate
2. Android Studio – Bundled with Studio 3.0, plugin available for earlier versions
3. Eclipse – Install the plugin from the Eclipse Marketplace
4. Compiler – Use any editor and build from the command line.
Leave a Reply