(original) Java extension language:. Kotlin Practice-Basic installation and use

Source: Internet
Author: User

Kotlin is a new JVM-based language that can be seen as the extended language of Java, developed by JetBrains, who first saw him in the company's Android team when they saw them using the Kotlin to develop Android, suddenly feeling curious, and then slowly studied the prophecy.

Why to develop and use the Kotlin language, the official saying is:

Concise safeversatileinteroperable

And cite an example:

Nullif for youfun calculatetotal (obj:any) {  if  (obj is Invoice) {    obj.calculatetotal ()  }}

See here I probably understand, and then I want to say: roll

Installation:

One: in click Download kotlin download Kotlin binary files or drag the source on GitHub, I am using the source code compiled, but the result is the following structure:

Second: Start configuring environment variables:

Export kotlin_home=xxxxxxx/kotlincexport PATH=${path}:${kotlin_home}/bin

Very basic environment variables, Linux, not much to say.

Three: Write HelloWorld (hello.kt):

Fun Main (args:array<string>) {    println ("Hello, world!" )}

Four: Start compiling and running:

KOTLINC-JVM hello.kt-include-runtime--jar Hello.jar

At this point, we've written out a HelloWorld code using the Kotlin syntax, and we've compiled a jar, and it's going to run directly with main, and then we'll start analyzing the jar:

We see that the jar that it generates is also a Java class containing a main, and the main method in Java can be final decorated.

(original) Java extension language:. Kotlin Practice-Basic installation and use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.