class Duotai
{
private int num;
Duotai(int num)
{
this.num = num;
}
public boolean equals(Object obj)
{
if(obj instanceof Duotai)
{
Duotai d = (Duotai)obj;
return this.num == d.num;
}
}
}
class DuotaiDemoTest
{
public static void main(String[] args)
{
Duotai d1 = new Duotai(1);
Duotai d2 = new Duotai(1);
System.out.println(d1.equals(d2));
}
编译结果如下:
-----------------------------------------------------------------
G:\代码>javac DuotaiDemoTest.java
DuotaiDemoTest.java:21: 错误: 缺少返回语句
}
^
1 个错误
请问:问题出在哪里?不是已经有了return语句了吗?
|
|