javaÖÐequalsºÍ==µÄÇø±ð
ÖµÀàÐÍÊÇ´æ´¢ÔÚÄÚ´æÖеĶÑÕ»£¨ÒÔºó¼ò³ÆÕ»£©£¬¶øÒýÓÃÀàÐ͵ıäÁ¿ÔÚÕ»Öнö½öÊÇ´æ´¢ÒýÓÃÀàÐͱäÁ¿µÄµØÖ·£¬¶øÆä±¾ÉíÔò´æ´¢ÔÚ¶ÑÖС£
==²Ù×÷±È½ÏµÄÊÇÁ½¸ö±äÁ¿µÄÖµÊÇ·ñÏàµÈ£¬¶ÔÓÚÒýÓÃÐͱäÁ¿±íʾµÄÊÇÁ½¸ö±äÁ¿ÔÚ¶ÑÖд洢µÄµØÖ·ÊÇ·ñÏàͬ£¬¼´Õ»ÖеÄÄÚÈÝÊÇ·ñÏàͬ¡£
equals²Ù×÷±íʾµÄÁ½¸ö±äÁ¿ÊÇ·ñÊǶÔͬһ¸ö¶ÔÏóµÄÒýÓ㬼´¶ÑÖеÄÄÚÈÝÊÇ·ñÏàͬ¡£
==±È½ÏµÄÊÇ2¸ö¶ÔÏóµÄµØÖ·£¬¶øequals±È½ÏµÄÊÇ2¸ö¶ÔÏóµÄÄÚÈÝ¡£
ÏÔÈ»£¬µ±equalsΪtrueʱ£¬==²»Ò»¶¨Îªtrue£»
Ò»¡¢StringÖеÄequalsºÍ==
1¡¢
public class TestString {
public static void main(String[] args) {
String s1 = "Monday";
String s2 = "Monday";
}
}
ÉÏÃæÕâ¶Î³ÌÐòÖУ¬µ½µ×Óм¸¸ö¶ÔÏóÄØ£¿
À´¼ì²âһϰɣ¬ÉÔ΢¸Ä¶¯Ò»Ï³ÌÐò
public class TestString {
public static void main(String[] args) {
String s1 = "Monday";
String s2 = "Monday";
if (s1 == s2)
System.out.println("s1 == s2");
else
System.out.println("s1 != s2");
}
}
±àÒë²¢ÔËÐгÌÐò£¬Êä³ö£ºs1 == s2
˵Ã÷£ºs1 Óë s2 ÒýÓÃͬһ¸ö String ¶ÔÏó -- "Monday"!
2.
ÔÙÉÔ΢¸Ä¶¯Ò»Ï³ÌÐò£¬»áÓиüÆæ¹ÖµÄ·¢ÏÖ£º
public class TestString {
public static void main(String[] args) {
String s1 = "Monday";
String s2 = new String("Monday");
if (s1 == s2)
System.out.println("s1 == s2");
else
&nb
Ïà¹ØÎĵµ£º
ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖƵÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......
¹Ø¼ü×Ö: thread
³ÌÐòÊǺܼòÒ׵ġ£È»¶ø£¬ÔÚ±à³ÌÈËÔ±ÃæÇ°£¬¶àÏ̳߳ÊÏÖ³öÁËÒ»×éеÄÄÑÌ⣬Èç¹ûûÓб»Ç¡µ±µÄ½â¾ö£¬½«µ¼ÖÂÒâÍâµÄÐÐΪÒÔ¼°Ï¸Î¢µÄ¡¢ÄÑÒÔ·¢ÏֵĴíÎó¡£
ÔÚ±¾ÆªÎÄÕÂÖУ¬ÎÒÃÇÕë¶ÔÕâЩÄÑÌâÖ®Ò»£ºÈçºÎÖжÏÒ»¸öÕýÔÚÔËÐеÄÏ̡߳£
Öжϣ¨Interrupt£©Ò»¸öÏß³ÌÒâζ×ÅÔÚ¸ÃÏß³ÌÍê³ÉÈÎÎñ֮ǰֹͣÆäÕýÔÚ½øÐеÄÒ»ÇУ ......
ÒÔÏÂÊÇʵÏÖ¹ý³Ì£¬½ö¹©²Î¿¼:
JAVA_HOMEÊÇ C:\jdk1.6.0_02
PathÊÇ %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
CLASSPATHÊÇ .;%JAVA_HOME%lib;%JAVA_HOME%lib\tools.jar
ÓÃ Java
ͨ¹ý´®¿Ú·¢¶ÌÐÅÆäʵºÜ¼òµ¥£¬ÒòΪÓÐÏֳɵÄÀà¿â¹©ÎÒÃÇʹÓá£ÓеײãµÄÀà¿â£¬Ò²Óзâ×°ºÃÒ»µãµÄÀà¿â£¬ÏÂÃæÎÒ½éÉÜÒ»ÏÂÔÚ Win32 ƽ̨Ï·¢ËͶÌÐŵķ½·¨¡£
......
JAVA£×Ö·û´®¹ýÂËÀà
package cn.com.hbivt.util;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class StringUtils {
/ ......
package cn.com.hbivt.util;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class StringUtils {
//¹ýÂËͨ¹ýÒ³Ãæ±íµ¥Ìá½» ......