首页 > 其他 > 详细

重写equals和toString

时间:2015-06-19 21:50:10      阅读:288      评论:0      收藏:0      [点我收藏+]

public class Cell {

public int x;

public int y;

public Cell(int x, int y){

this.x = x;

this.y =y;

}

public String toString(){

return +x+","+y;

}

public boolean equals(Object obj){

if(this == obj){

return true;

}

if(obj == null){

return false;

}

if(obj instanceof Cell){

Cell c = (Cell) obj;

return this.x == c.x && this.y == c.y;

}else{

return false;

}

}


重写equals和toString

原文:http://skieshawk.blog.51cto.com/4683228/1663392

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!