首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

判断两个种是否相等

2012-08-25 
判断两个类是否相等public class TestVo {???private String vc2Key??????@Override?public boolean equa

判断两个类是否相等


public class TestVo {
?
?
?private String vc2Key;
?
?
?
?
?

?@Override
?public boolean equals(Object obj) {
??//if(this.vc2Key.equals(((TestVo)obj).getVc2Key())){
??if(this.vc2Key==((TestVo)obj).getVc2Key()){
???return true;
??}else{
???return false;
??}
?}

?public String getVc2Key() {
??return vc2Key;
?}

?public void setVc2Key(String vc2Key) {
??this.vc2Key = vc2Key;
?}
?

}

?

?

?

?

?

?

?

public class Test {/** * @param args */public static void main(String[] args) {TestVo testVo1=new TestVo();testVo1.setVc2Key("aaa");TestVo testVo2=new TestVo();testVo2.setVc2Key("aaa");System.out.println(testVo1.equals(testVo2));}}

?

热点排行