简体   繁体   English

Kotlin:自定义类实例上未解析的引用

[英]Kotlin: Unresolved reference on custom class instance

I have a Kotlin class named HttpsAuthenticator .我有一个名为HttpsAuthenticator的 Kotlin 类。 The file in which that class resides is also by the same name.该类所在的文件也具有相同的名称。 HttpsAuthenticator has an inner class named XYZ. HttpsAuthenticator有一个名为 XYZ 的内部类。 Here is the code:这是代码:

public class HttpsAuthenticator
{
    public class XYZ{

    }
}

在此处输入图片说明

From another class, when I instantiate each of those two classes, HttpsAuthenticator() fails with the error Unresolved reference .在另一个类中,当我实例化这两个类中的每一个时, HttpsAuthenticator()失败并显示错误Unresolved reference What is the difference.有什么不同。 How do I instantiate HttpsAuthenticator ?如何实例化HttpsAuthenticator Im absolutely new to Kotlin so I must be missing something basic I believe?我对 Kotlin 完全陌生,所以我一定缺少一些我认为的基本知识?

What ended up fixing it was simply adding import HttpsAuthenticator最终修复它只是添加import HttpsAuthenticator

Why XYZ was visible before that is beyond my comprehension at the moment.为什么在此之前 XYZ 是可见的,目前我无法理解。 Im sure someone will come up with an explanation to this.我相信有人会对此做出解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM