-1

I am new in kotlin , I started to learn Kotlin Language by installing intellij IDEA , now the issue is when i want to run second .kt file by run button its only showing what i had run first .kt file .

Image One Here

Image Two here

Always showing Run HelloWorld.kt, I want to run Addition.kt

I am no able to run new crated class in kotlin, it's only showing the first class what I had run first time in the project.

ɢʀᴜɴᴛ
  • 32,025
  • 15
  • 116
  • 110
Abhishek kumar
  • 4,347
  • 8
  • 29
  • 44

2 Answers2

2

Just use the tiny Kotlin button on the left side of your main method to run this one. This should do the trick.

Alternatively, you can "edit" your run configuration to point to the desired main method.

s1m0nw1
  • 76,759
  • 17
  • 167
  • 196
0

You can set the class to run using the edit configurations panel screenshot
There you can create a new configuration to run the second class or edit the default configuration to start the second class.

But this may be unnecessarily complicated for a beginner and is rarely needed for any project.
You should probably try either:

  • Just run your multiple test statements in the same main method
  • Create a top level function in any class and call that from the main method
  • Start learning to use classes and objects and create them from the main method.
RobCo
  • 6,240
  • 2
  • 19
  • 26