构造函数不可见 [英] Constructor not visible
本文介绍了构造函数不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个Android应用程序,该应用程序使用 ScanResult
对象.该对象的形式为:
I am developing an Android application which makes use of the ScanResult
object. This object is in the form of:
[SSID: __mynetwork__, BSSID: 00:0e:2e:ae:4e:85, capabilities: [WPA-PSK-TKIP][ESS], level: -69, frequency: 2457, timestamp: 117455824743]
我试图通过创建自己的扩展ScanResult
的类来覆盖此类的equals()
方法:
I am trying to override the equals()
method of this class by creating my own class which extends ScanResult
:
public class MyScanResult extends ScanResult {
public MyScanResult() {
super();
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof ScanResult))
return false;
ScanResult obj = (ScanResult) obj;
if (!BSSID.equals(obj.BSSID))
return false;
if (!SSID.equals(obj.SSID))
return false;
if (!capabilities.equals(obj.capabilities))
return false;
if (frequency != obj.frequency)
return false;
if (level != obj.level)
return false;
return true;
}
}
但是,当我尝试此操作时,出现以下错误:The constructor ScanResult() is not visible
.我该如何解决?
However when I try this, I get the following error: The constructor ScanResult() is not visible
. How can I solve this please?
推荐答案
ScanResult
的公共构造函数签名为:
The public constructor signature for ScanResult
is:
public ScanResult(String SSID, String BSSID, String caps, int level, int frequency)
您需要调用具有匹配参数的超类
You need to invoke the super class with matching parameters
这篇关于构造函数不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文