码迷,mamicode.com
首页 > 编程语言 > 详细

Java考查“==”和equals

时间:2015-04-02 20:58:08      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:java   equals   面试题   

/**
 * 
 */
package com.you.demo;

/**
 * @author YouHaiDong
 * @date 2015-04-02
 */
public class Welcome 
{
	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		String str1 = "you";
		String str2 = "you";
		String str3 = new String("you");
		System.out.println(str1==str2);
		System.out.println(str1==str3);
		System.out.println(str2.equals(str3));
	}

}

结果为:

true
false
true


Java考查“==”和equals

标签:java   equals   面试题   

原文地址:http://blog.csdn.net/you23hai45/article/details/44836523

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!