Kotlin Help

Create your first Kotlin Notebook

Here, you will learn how to create your first Kotlin Notebook, perform simple operations, and run code cells.

Create an empty project

  1. In IntelliJ IDEA, select File | New | Project.

  2. In the panel on the left, select New Project.

  3. Name the new project and change its location if necessary.

  4. From the Language list, select Kotlin.

    Create a new Kotlin Notebook project
  5. Select the IntelliJ build system.

  6. From the JDK list, select the JDK that you want to use in your project.

  7. Enable the Add sample code option to create a file with a sample "Hello World!" application.

  8. Click Create.

Create a Kotlin Notebook

  1. To create a new notebook, select File | New | Kotlin Notebook, or right-click on a folder and select New | Kotlin Notebook.

    Create a new Kotlin Notebook
  2. Set the name of the new notebook, for example, first-notebook, and press Enter. A new tab with a Kotlin Notebook first-notebook.ipynb will open.

  3. In the open tab, type the following code in the code cell:

    println("Hello, this is a Kotlin Notebook!")
  4. To run a code cell, click the Run Cell and Select Below Run Cell and Select Below button or press Shift + Return.

  5. Add a markdown cell by clicking on the Add Markdown Cell button.

  6. Type # Example operations in the cell, and run it the same way you run code cells to render it.

  7. In a new code cell, type 10 + 10 and run it.

  8. Define a variable in a code cell. For example, val a = 100.

  9. Create a new code cell and add println(a * a).

  10. Run all code and markdown cells in the notebook using the Run All Run all button button.

First notebook

Congratulations! You have just created your first Kotlin Notebook.

Next step

In the next part of the tutorial, you will learn how to add dependencies to a Kotlin Notebook.

Proceed to the next chapter

Last modified: 12 April 2024