- Kotlin for Enterprise Applications using Java EE
- Raghavendra Rao K
- 167字
- 2021-06-10 18:49:25
Creating a simple Kotlin project
It's easy to create a Kotlin-JVM project using IntelliJ IDEA by observing the following steps:
- Click on File | New | Project.
- In the New Project window, select Kotlin/JVM, and choose Next. This is shown in the following screenshot:
- In the next wizard, specify the Project name and the Project location. Choose JDK and Kotlin runtime and click on Finish.
- In the modules settings, click on Facets and add Kotlin to the module.
- We have now created a simple Kotlin project. We can write the code here in Kotlin:
- Under the source (src) directory, we can create the Kotlin files:
Now let's write a simple program to find the factorial of a number. Consider the following Factorial.kt file:
fun main(args: Array<String>) {
val number = 5
var factorial: Int = 1
for (i in 1..number) {
factorial *= i
}
println("Factorial of $number = $factorial")
}
The output is as follows:
推薦閱讀
- jQuery Mobile Web Development Essentials(Third Edition)
- Flask Blueprints
- LabVIEW2018中文版 虛擬儀器程序設計自學手冊
- Rust編程:入門、實戰與進階
- 人人都是網站分析師:從分析師的視角理解網站和解讀數據
- CKA/CKAD應試教程:從Docker到Kubernetes完全攻略
- Java網絡編程核心技術詳解(視頻微課版)
- Python Essentials
- Red Hat Enterprise Linux Troubleshooting Guide
- Python函數式編程(第2版)
- 從Excel到Python數據分析:Pandas、xlwings、openpyxl、Matplotlib的交互與應用
- Scala Functional Programming Patterns
- Ext JS 4 Plugin and Extension Development
- Apache Solr PHP Integration
- 深入理解Kafka:核心設計與實踐原理