How can i solve the Array problem in Kotlin?

半腔热情 提交于 2021-01-29 07:53:50

问题


When I try to compile some basic array code I get errors. I tried to re-install IntelliJ and I made all updates.

fun main(args: Array<String>) {
    val numbers = intArrayOf(1, 4, 42, -3)
    if (4 in numbers) {
        println("numbers array contains 4.")
    }
}

Here are the errors.

Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/KotlinPackage
    at KtlneKt.main(ktlne.kt:2)
    at KtlneKt.main(ktlne.kt)
    Caused by: java.lang.ClassNotFoundException: kotlin.KotlinPackage
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 2 more

Process finished with exit code 1

回答1:


Same question. So same answer: I had the same problem and I discovered that this is a bug of Kotlin library. You cannot call intArrayOf() method.

I am sure that you are using Windows 10 Single Language Turkish. (I was using the same operating system.) Kotlin's some libraries cannot work on Turkish operating system. You can check this issue on YouTrack.

You can solve your problem with installing Windows 10 Pro English or Windows 10 Single Language English. I do not know any other approach right now. (You can open new issue on Kotlin website.)

This bug took from me 30 days. You can check my related question about this Kotlin bug.



来源:https://stackoverflow.com/questions/57755750/how-can-i-solve-the-array-problem-in-kotlin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!