Kotlin as New Language to Develop Android applications
Kotlin is expressive, concise, extensible, powerful, and a joy to read and write. It has wonderful safety features in terms of null ability and immutability, which aligns with our investments to make Android apps healthy and performance by default. Best of all, it's inter operable with our existing Android languages and run time. So we're thrilled to make Kotlin an official language on Android.
If you're interested in using Kotlin, it's easy to get started because it works side by side with Java and C++ on Android. So you can keep your existing code, continue to use the various Android libraries, and incrementally add Kotlin code to your project. Unlike almost any other language, Kotlin is a drop-in replacement you can use bi-bidirectionally—you can call into the Java language from Kotlin, and you can call into Kotlin from the Java language.
IDE support is also crucial, and android studio have it. Android Studio is built upon IntelliJ IDEA, an IDE built by JetBrains—the same company that created the Kotlin language. The JetBrains team has been working for years to make sure Kotlin works great with IntelliJ IDEA.Starting with Android Studio 3.0, tooling support for Kotlin is bundled directly into Android Studio.
Kotlin is an excellent fit for Android not only because it gives developers what they want, but also because it matches the spirit of Android. Just like Android, Kotlin has always been an open source project, primarily under Apache 2. It involves an entire community and does not belong to just one company.
Kotlin is fully supported in Android Studio 3.0 so it's easy to create new projects with Kotlin files, add Kotlin files to your existing project, and convert Java language code to Kotlin. You can then use of all Android Studio's existing tools with your Kotlin code, such as autocomplete, lint checker, refactoring, debugging, and more.
Create New Project With Kotlin:-
In Android Studio, click File > New > New Project. Or if you've just opened Android Studio and see the Welcome to Android Studio window, click Start a new Android Studio project.
On the first screen, check Include Kotlin support. That's the only difference.
Click Next and continue through the wizard until you're done.
Add Kotlin to an existing project:-
If you want to add Kotlin code to an existing project, simply click File > New and select one of the various Android templates. If you don't see the list of templates in this menu, first open the Project window and select your app module.
In the wizard that appears, select Kotlin for the Source language.
Alternatively, you can click File > New > Kotlin File/Class to create a basic file. The New Kotlin File/Class window provides several choices for the kind of file, but it doesn't matter which one you choose because Kotlin switches the file type automatically if you later change the declaration type.
Convert existing Java code to Kotlin code:-
In Android Studio 3.0, open a Java file and select Code > Convert Java File to Kotlin File.
Or, create a new Kotlin file (File > New > Kotlin File/Class), and then paste your Java code into that file—when prompted, click Yes to convert the code to Kotlin. You can check Don't show this dialog next time, which makes it easy to dump Java code snippets into your Kotlin files.
Use Android APIs with Kotlin:-
Kotlin provides complete inter operability with java language, so calling the Android APIs often looks exactly like the matching Java code. Except now you can combine those method calls with Kotlin's syntax features.
Main Features Of Kotlin Language:-
Kotlin is simpler language than Java.
Java codes can be converted into kotlin.
Kotlin language is majorly used for android development.
Suitable and supported for Android Studio 3.0
It is possible to write code in java and then convert it into kotlin.
Comments
Post a Comment