官术网_书友最值得收藏!

Setting up a Kotlin project with IntelliJ

The process of setting up a Kotlin project with IntelliJ is straightforward:

  1. Start the IntelliJ IDE application.
  2. Click Create New Project.
  1. Select Java from the available project options on the left-hand side of the newly opened window.
  2. Add Kotlin/JVM as an additional library to the project.
  3. Pick a project SDK from the drop-down list in the window.
  4. Click Next.
  5. Select a template if you wish to use one, then continue to the next screen.
  6. Provide a project name in the input field provided. Name the project HelloWorld for now.
  7. Set a project location in the input field.
  8. Click Finish.

Your project will be created and you will be presented with the IDE window:

To the left of the window, you will immediately see the project view. This view shows the logical structure of your project files.

Two folders are present. These are:

  • .idea: This contains IntelliJ's project-specific settings files.
  • src: This is the source folder of your project. You will place your program files in this folder.

Now that the project is set up, we will write a simple program. Add a file named hello.kt to the source folder (right-click the src folder, select New | Kotlin File/Class, and name the file hello). Copy and paste the following code into the file:

fun main(args: Array<String>) {
println("Hello world!")
}

To run the program, click the Kotlin logo adjacent to the main function and select Run HelloKt:

The project will be built and run, after which, Hello world! will be printed to the standard system output.

主站蜘蛛池模板: 瑞丽市| 确山县| 吉林省| 汪清县| 湖口县| 广州市| 通许县| 滁州市| 商水县| 龙门县| 仙游县| 金寨县| 外汇| 崇信县| 赫章县| 安顺市| 绍兴市| 南和县| 应城市| 新晃| 漳州市| 娱乐| 鹰潭市| 房产| 铜鼓县| 红桥区| 新田县| 读书| 临朐县| 六安市| 田东县| 秀山| 三河市| 扬州市| 确山县| 绥江县| 大理市| 银川市| 中阳县| 克东县| 萝北县|