JavaѧϰʰÒÅ2
»°ÌâÊÇÓÉÈçϵÄÊÂÇéÒý³öµÄ£º public class StringTest { public static void main(String[] args) { String str1 = new String("abc"); String str2 = "abc"; if (str1 == str2) { System.out.println("str1 == str2"); } else { System.out.println("str1 != str2"); } String str3 = "abc"; if (str2 == str3) { System.out.println("str2 == str3"); } else { System.out.println("str2 != str3"); } str1 = str1.intern(); if (str1 == str2) { System.out.println("str1 == str2"); } else { System.out.println("str1 != str2"); } String str4 = new String("abc"); str4 = str4.intern(); if (str1 == str4) { System.out.println("str1 == str4"); } else { System.out.println("str1 != str4"); } }
Ïà¹ØÎĵµ£º
Java ÀíÂÛºÍʵ¼ù: Á˽ⷺÐÍ Ê¶±ðºÍ±ÜÃâѧϰʹÓ÷ºÐ͹ý³ÌÖеÄÏÝÚå
JDK 5.0 ÖÐÔö¼ÓµÄ·ºÐÍÀàÐÍ£¬ÊÇ Java ÓïÑÔÖÐÀàÐÍ°²È«µÄÒ»´ÎÖØÒª¸Ä½ø¡£µ«ÊÇ£¬¶ÔÓÚ³õ´ÎʹÓ÷ºÐÍÀàÐ͵ÄÓû§À´Ëµ£¬·ºÐ͵ÄijЩ·½Ãæ¿´ÆðÀ´¿ÉÄܲ»ÈÝÒ×Ã÷°×£¬ÉõÖÁ·Ç³£Ææ¹Ö¡£ÔÚ±¾ÔµÄ"Java Àí ......
1.1 ²»ÓÃnew¹Ø¼ü´Ê´´½¨ÀàµÄʵÀý
ÓÃnew¹Ø¼ü´Ê´´½¨ÀàµÄʵÀýʱ£¬¹¹Ô캯ÊýÁ´ÖеÄËùÓй¹Ô캯Êý¶¼»á±»×Ô¶¯µ÷Óᣵ«Èç¹ûÒ»¸ö¶ÔÏóʵÏÖÁËCloneable½Ó¿Ú£¬ÎÒÃÇ¿ÉÒÔµ÷ÓÃËüµÄclone()·½·¨¡£clone()·½·¨²»»áµ÷ÓÃÈκÎÀ๹Ô캯Êý¡£
ÔÚʹÓÃÉè¼Æģʽ£¨Design Pattern£©µÄ³¡ºÏ£¬Èç¹ûÓÃFactoryģʽ´´½¨¶ÔÏó£¬Ôò¸ÄÓÃclone()·½·¨´´½¨Ðµ ......
java¶à̬µÄ2ÖÖ±íÏÖÐÎʽ ·½·¨ÖØÔغͷ½·¨¸²¸Ç
·½·¨ÖØÔØ£ºÍ¬Ò»¸öÀàÖУ¬·½·¨ÃûÏàͬ£¬²ÎÊýÁÐ±í²»Í¬µÄ2¸ö»ò¶à¸ö·½·¨¹¹³É·½·¨µÄÖØÔØ¡£
·½·¨¸²¸Ç£º×ÓÀàÖØÐÂʵÏÖÁ˸¸ÀàÖеķ½·¨¡£
·½·¨ÖØÔØ
/**
* ·½·¨ÖØÔØÂú×ãµÄÌõ¼þ
* ͬһ¸öÀàÖУ¬·½·¨ÃûÏàͬ£¬²ÎÊýÁÐ±í²»Í¬µÄ2¸ö»ò¶à¸ö·½·¨¹¹³É·½·¨µÄÖØÔØ
* ²ÎÊýÁÐ±í²»Í¬Ö¸²ÎÊýµÄÀàÐÍ£¬²Î ......
JAVA_HOME = F:\java\jdk £¨jdk°²×°Â·¾¶£©
PATH = .;%JAVA_HOME%/bin
CLASSPTAH = .;%JAVA_HOME%/lib
¼ìÑéÊÇ·ñÅäÖóɹ¦£º
¿ØÖÆ̨cmd
ÊäÈëjava³öÏÖÅäÖÃÐÅϢ˵Ã÷ÅäÖóɹ¦¡£ ......