Class not found in module

I made a project using kotlin:

Group id-> com.programming.kotlin Artifact id->chapter01 Module name->chapter01 package->com.programming.kotlin.chapter01 

I created a kotlin class called Program.kt

The problem is that when I try to create a new class (called Program2.kt) inside the package, and when I try to start it, I got this error:

 class com.programming.kotlin.chapter01.Program2kt not found in module 'chapter01_main' 

My question is: how to allow any new class other than the Main class to run inside intellij?

+7
source share
2 answers

Your class name should be com.programming.kotlin.chapter01.Program2 . If you go to InteliJ and right-click on the class, you can click the Copy Reference link, which will copy the class link (package and class name).

Kt (capitalized K) is added only to functions without an enclosing class or object.

0
source

I have this code:

class StoryTeller (val story: Story) {

 fun render(id: String?): StoryTeller { if (id == null) return this if ( ! story.items.containsKey(id)) { throw Exception("Story does not contain an item with key \"$id\"") } val item = story.items.get(id)!! item.render(this)........... At startup it gives this error: 

Class 'MainKt' not found in module 'Kotlin1' What should I do?

0
source

Source: https://habr.com/ru/post/1269537/


All Articles