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
Ïà¹ØÎĵµ£º
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔǰ£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
mysqlÊý¾Ý¿â±¾ÉíÓÐÊý¾Ý±¸·ÝºÍÅúÁ¿Êý¾Ý²åÈëµÄÃüÁjava´úÂë¿ÉÖ´ÐÐÕâЩÃüÁî¡£
°²×°mysqlºó£¬ÐèÒªÉèÖû·¾³±äÁ¿£ºÎҵĵçÄÔÓÒ»÷--ÊôÐÔ--¸ß¼¶--»·¾³±äÁ¿£¬Ôö¼ÓMYSQL_HOME=“mysql°²×°Â·¾¶”£¬È»ºópath=%MYSQL_HOME%\bin
´úÂëÈçÏ£º
import java.io.BufferedReader;
import java.io.FileInputStream;
import java. ......
ÐòÁл¯»úÖÆÖ»±£´æ¶ÔÏóµÄÀàÐÍÐÅÏ¢£¬ÊôÐÔµÄÀàÐÍÐÅÏ¢ºÍÊôÐÔÖµ£¬ºÍ·½·¨Ã»ÓÐʲô¹ØÏµ£¬Äã¾ÍÊǸøÕâ¸öÀàÔö¼Ó10000¸ö·½·¨£¬ÐòÁл¯ÄÚÈÝÒ²²»»áÔö¼ÓÈκζ«Î÷
¼òµ¥À´ËµÐòÁл¯¾ÍÊÇÒ»ÖÖÓÃÀ´´¦Àí¶ÔÏóÁ÷µÄ»úÖÆ£¬Ëùν¶ÔÏóÁ÷Ò²¾ÍÊǽ«¶ÔÏóµÄÄÚÈݽøÐÐÁ÷»¯£¬Á÷µÄ¸ÅÄîÕâÀï²»Óöà˵(¾ÍÊÇI/O)£¬ÎÒÃÇ¿ÉÒÔ¶ÔÁ÷»¯ºóµÄ¶ÔÏó½øÐжÁд²Ù×÷£¬Ò²¿É ......
ÓиÐ:ӦƸJava±ÊÊÔʱ¿ÉÄܳöÏÖÎÊÌâ¼°Æä´ð°¸
ǰ¶Îʱ¼äÒòΪҪ²Î¼ÓÒ»¸ö±ÊÊÔ£¬ÔÚ×¼±¸ÆÚ¼äÔÚÍøÉÏÕÒµ½ÁËÁ½Ìõ¹ØÓÚ±ÊÊÔÌâÄ¿µÄÎÄÕ£¬ÆäÖÐһƪΪ<<ÓиÐ:ӦƸJava±ÊÊÔʱ¿ÉÄܳöÏÖÎÊÌâ>>£¬»¹ÓÐһƪÍüÁËÃû×Ö£¬¶ÁºóÉîÊÜÆô·¢¡£
ÔÚѰÕÒÕâЩ´ð°¸µÄ¹ý³ÌÖУ¬ÎÒ½«Ïà¹Ø´ð°¸¼Ç¼ÏÂÀ´£¬¾ÍÐγÉÁËÒÔÏÂÕâЩ¶«Î÷¡£ÐèҪ˵à ......
ÖµÀàÐÍÊÇ´æ´¢ÔÚÄÚ´æÖеĶÑÕ»£¨ÒÔºó¼ò³ÆÕ»£©£¬¶øÒýÓÃÀàÐ͵ıäÁ¿ÔÚÕ»Öнö½öÊÇ´æ´¢ÒýÓÃÀàÐͱäÁ¿µÄµØÖ·£¬¶øÆä±¾ÉíÔò´æ´¢ÔÚ¶ÑÖС£
==²Ù×÷±È½ÏµÄÊÇÁ½¸ö±äÁ¿µÄÖµÊÇ·ñÏàµÈ£¬¶ÔÓÚÒýÓÃÐͱäÁ¿±íʾµÄÊÇÁ½¸ö±äÁ¿ÔÚ¶ÑÖд洢µÄµØÖ·ÊÇ·ñÏàͬ£¬¼´Õ»ÖеÄÄÚÈÝÊÇ·ñÏàͬ¡£
equals²Ù×÷±íʾµÄÁ½¸ö±äÁ¿ÊÇ·ñÊǶÔͬһ¸ö¶ÔÏóµÄÒýÓ㬼´¶ÑÖеÄÄÚÈÝÊÇ ......