`
caryt
  • 浏览: 8579 次
文章分类
社区版块
存档分类
最新评论

JAVA对象的比较测试

 
阅读更多
/**
*
* @author caryt
*
*/
public class test {

/**
* @param args
*/
static int x[]=new int[15];
public static void main(String[] args) {
// TODO Auto-generated method stub
String t1=new String("caryt");
String t2=new String("caryt");
System.out.println(t1==t2);//比较的是对象的引用
System.out.println(t1!=t2);//比较的是对象的引用

System.out.println(t1.equals(t2));//比较的是对象的

}

}

out:false
true
true

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics