当前位置: 代码迷 >> Eclipse >> 简单的有关问题弄不明白啊气愤,求教
  详细解决方案

简单的有关问题弄不明白啊气愤,求教

热度:4   发布时间:2016-04-23 13:41:07.0
简单的问题弄不明白啊,气愤,求教。
以下程序为什么输出是0呢!
public class test 
{
  int x,y;
  void set(){}
   

   
   
public static void main(String args[])
{
test c=new test();
c.x=1;
c.y=1;

test d=new test();
d.x=1;
d.y=1;

if(c.equals(d)) System.out.println(1);
else System.out.println(0);
}

}

------解决方案--------------------
探讨
并且两对象 也不是引用一个实例 用equals()能返回true。
  相关解决方案