【发布时间】:2014-05-27 15:23:10
【问题描述】:
这是我的班级的样子。
public class MyFirstClass
{
private FirstInterface firstInterface;
public FirstInterface getFirstInterface() {
return firstInterface;
}
public void setFirstInterface(FirstInterface firstInterface) {
this.firstInterface = firstInterface;
aMethod()
{
firstInterface.getMyFunction();
System.out.println(firstInterface); // prints some object value here.
{
}
界面:
public abstract interface FirstInterface
{
public abstract getMyFunction();
}
以及实现类:
public class MyImplClass implements MyFirstClass
{
}
我在这里找不到构造函数或任何其他初始化。有人请告诉我不同的方式,firstInterface 是如何初始化的?
【问题讨论】:
-
您的问题不清楚。你的界面是否应该被称为
FirstInterface?您是在询问MyFirstClass中的firstInterface字段吗? -
我也不懂你的问题,你能用简单的英语告诉我们你真正想要做什么吗?
-
MyFirstClass 中似乎缺少一些代码(在
this.firstInterface = firstInterface;和aMethod()之间) -
是的。我试图打印
firstInterface,它打印了一些对象值。这个对象是从哪里分配的? -
@KonstantinNaryshkin:这是一个错字。编辑了问题..
标签: java