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

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.

主站蜘蛛池模板: 松溪县| 柳林县| 玛多县| 黄石市| 迁安市| 曲沃县| 榕江县| 哈尔滨市| 肃宁县| 永登县| 社会| 墨竹工卡县| 武川县| 铁岭县| 泊头市| 榆中县| 英德市| 雷山县| 陆川县| 郎溪县| 平果县| 临西县| 正蓝旗| 呼图壁县| 亚东县| 麻江县| 利津县| 新绛县| 裕民县| 万盛区| 凤台县| 金塔县| 清苑县| 汤阴县| 绥江县| 庄河市| 衡阳市| 科技| 承德县| 常熟市| 建水县|