- 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:
推薦閱讀
- Mastering Kali Linux for Web Penetration Testing
- Full-Stack React Projects
- Oracle從入門到精通(第5版)
- 小學生C++創意編程(視頻教學版)
- C和C++游戲趣味編程
- Building Microservices with .NET Core
- INSTANT Adobe Edge Inspect Starter
- Scratch趣味編程:陪孩子像搭積木一樣學編程
- C語言程序設計習題與實驗指導
- Raspberry Pi Robotic Blueprints
- 自學Python:編程基礎、科學計算及數據分析(第2版)
- Applied Deep Learning with Python
- Building Microservices with Go
- Mastering VMware vSphere Storage
- 秒懂算法:用常識解讀數據結構與算法