Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java stringÀàÏê½â

Java×Ö·û´®Àà(java.lang.String)ÊÇJavaÖÐʹÓÃ×î¶àµÄÀ࣬ҲÊÇ×îΪÌØÊâµÄÒ»¸öÀ࣬ºÜ¶àʱºò£¬ÎÒÃǶÔËü¼ÈÊìϤÓÖÄ°Éú¡£
 
Ò»¡¢´Ó¸ù±¾ÉÏÈÏʶjava.lang.StringÀàºÍString³Ø
 
Ê×ÏÈ£¬ÎÒ½¨ÒéÏÈ¿´¿´StringÀàµÄÔ´ÂëʵÏÖ£¬ÕâÊÇ´Ó±¾ÖÊÉÏÈÏʶStringÀàµÄ¸ù±¾³ö·¢µã¡£´ÓÖпÉÒÔ¿´µ½£º
1¡¢StringÀàÊÇfinalµÄ£¬²»¿É±»¼Ì³Ð¡£public final class String¡£
2¡¢StringÀàÊǵı¾ÖÊÊÇ×Ö·ûÊý×échar[], ²¢ÇÒÆäÖµ²»¿É¸Ä±ä¡£private final char value[];
È»ºó´ò¿ªStringÀàµÄAPIÎĵµ£¬¿ÉÒÔ·¢ÏÖ£º
3¡¢StringÀà¶ÔÏóÓиöÌØÊâµÄ´´½¨µÄ·½Ê½£¬¾ÍÊÇÖ±½ÓÖ¸¶¨±ÈÈçString x = "abc"£¬"abc"¾Í±íʾһ¸ö×Ö·û´®¶ÔÏ󡣶øxÊÇ"abc"¶ÔÏóµÄµØÖ·£¬Ò²½Ð
×ö"abc"¶ÔÏóµÄÒýÓá£
4¡¢String¶ÔÏó¿ÉÒÔͨ¹ý“+”´®Áª¡£´®Áªºó»áÉú³ÉеÄ×Ö·û´®¡£Ò²¿ÉÒÔͨ¹ýconcat()À´´®Áª£¬Õâ¸öºóÃæ»á½²Êö¡£
6¡¢JavaÔËÐÐʱ»áά»¤Ò»¸öString Pool£¨String³Ø£©£¬JavaDoc·­ÒëºÜÄ£ºý“×Ö·û´®»º³åÇø”¡£String³ØÓÃÀ´´æ·ÅÔËÐÐʱÖвúÉúµÄ¸÷ÖÖ×Ö·û´®£¬
²¢ÇÒ³ØÖеÄ×Ö·û´®µÄÄÚÈݲ»Öظ´¡£¶øÒ»°ã¶ÔÏó²»´æÔÚÕâ¸ö»º³å³Ø£¬²¢ÇÒ´´½¨µÄ¶ÔÏó½ö½ö´æÔÚÓÚ·½·¨µÄ¶ÑÕ»Çø¡£
 
5¡¢´´½¨×Ö·û´®µÄ·½Ê½ºÜ¶à£¬¹éÄÉÆðÀ´ÓÐÈýÀࣺ
ÆäÒ»£¬Ê¹ÓÃnew¹Ø¼ü×Ö´´½¨×Ö·û´®£¬±ÈÈçString s1 = new String("abc");
Æä¶þ£¬Ö±½ÓÖ¸¶¨¡£±ÈÈçString s2 = "abc";
ÆäÈý£¬Ê¹Óô®ÁªÉú³ÉеÄ×Ö·û´®¡£±ÈÈçString s3 = "ab" + "c";
 
¶þ¡¢String¶ÔÏóµÄ´´½¨
 
String¶ÔÏóµÄ´´½¨Ò²ºÜ½²¾¿£¬¹Ø¼üÊÇÒªÃ÷°×ÆäÔ­Àí¡£
Ô­Àí1£ºµ±Ê¹ÓÃÈκη½Ê½À´´´½¨Ò»¸ö×Ö·û´®¶ÔÏósʱ£¬JavaÔËÐÐʱ£¨ÔËÐÐÖÐJVM£©»áÄÃ×ÅÕâ¸öXÔÚString³ØÖÐÕÒÊÇ·ñ´æÔÚÄÚÈÝÏàͬµÄ×Ö·û´®¶ÔÏó£¬
Èç¹û²»´æÔÚ£¬ÔòÔÚ³ØÖд´½¨Ò»¸ö×Ö·û´®s£¬·ñÔò£¬²»ÔÚ³ØÖÐÌí¼Ó¡£
 
Ô­Àí2£ºJavaÖУ¬Ö»ÒªÊ¹ÓÃnew¹Ø¼ü×ÖÀ´´´½¨¶ÔÏó£¬ÔòÒ»¶¨»á£¨ÔÚ¶ÑÇø»òÕ»Çø£©´´½¨Ò»¸öеĶÔÏó¡£
 
Ô­Àí3£ºÊ¹ÓÃÖ±½ÓÖ¸¶¨»òÕßʹÓô¿×Ö·û´®´®ÁªÀ´´´½¨String¶ÔÏó£¬Ôò½ö½ö»á¼ì²éά»¤String³ØÖеÄ×Ö·û´®£¬³ØÖÐûÓоÍÔÚ³ØÖд´½¨Ò»¸ö£¬ÓÐÔò°Õ
ÁË£¡µ«¾ø²»»áÔÚ¶ÑÕ»ÇøÔÙÈ¥´´½¨¸ÃString¶ÔÏó¡£
 
Ô­Àí4£ºÊ¹Óðüº¬±äÁ¿µÄ±í´ïʽÀ´´´½¨String¶ÔÏó£¬Ôò²»½ö»á¼ì²éά»¤String³Ø£¬¶øÇÒ»¹»áÔÚ¶ÑÕ»Çø´´½¨Ò»¸öString¶ÔÏó¡£
 
ÁíÍ⣬StringµÄintern()·½·¨ÊÇÒ»¸ö±¾µØ·½·¨£¬¶¨ÒåΪpublic native String intern(); intern()·½·¨µÄ¼ÛÖµÔÚÓÚÈÿª·¢ÕßÄܽ«×¢ÒâÁ¦¼¯Öе½
String³ØÉÏ¡£µ±µ÷Óà intern ·½·¨Ê±£¬Èç¹û³ØÒѾ­


Ïà¹ØÎĵµ£º

JavaÖеÄIOÁ÷֪ʶ×ܽᣨת£©

×ܽáÒ»£º
Java IOµÄÒ»°ãʹÓÃÔ­Ôò£º
Ò»¡¢°´Êý¾ÝÀ´Ô´£¨È¥Ïò£©·ÖÀࣺ
1¡¢ÊÇÎļþ£º FileInputStream, FileOutputStream, FileReader, FileWriter
2¡¢ÊÇbyte[]£ºByteArrayInputStream, ByteArrayOutputStream
3¡¢ÊÇChar[]: CharArrayReader, CharArrayWriter
4¡¢ÊÇString: StringBufferInputStream, StringReader, StringW ......

jsp,java±àÂëÔ­Àí

Îļþ´ò¿ªÊ±ºòÊÇͨ¹ýÎļþÍ·À´È·¶¨ÎļþµÄ±àÂë
StreamReader   sr=new   StreamReader(@"F:\cym\temp\1.txt");  
  sr.CurrentEncoding   //·µ»Ø±àÂë
ÊÀ½çÉϵĸ÷µØÇø¶¼Óб¾µØµÄÓïÑÔ¡£µØÇø²îÒìÖ±½Óµ¼ÖÂÁËÓïÑÔ»·¾³µÄ²îÒì¡£ÔÚ¿ª·¢Ò»¸ö¹ú¼Ê»¯³ÌÐòµÄ¹ý³ÌÖУ¬´¦ÀíÓïÑÔÎ ......

¡¶ÓûΪJava¼¼Êõ´óÅ£ËùÐèµÄ25¸öѧϰҪµã¡·¶Áºó¸Ð

½ñÈÕ¶Áµ½csdnµÄÐÂÎÅ¡¶ÓûΪJava¼¼Êõ´óÅ£ËùÐèµÄ25¸öѧϰҪµã¡·£¬Á˽âÒª×öÒ»¸öJava¼¼Êõ´óÅ£¿É²»ÊÇÒ»°ãÒ»°ãµÄ£¬ÌØÊÕ¼ÔÚ´Ë£ºÒÔ±Þ²ß×Ô¼º²»¶Ïѧϰ£º
1. ÄãÐèÒª¾«Í¨ÃæÏò¶ÔÏó·ÖÎöÓëÉè¼Æ(OOA/OOD)¡¢É漰ģʽ(GOF£¬J2EEDP)ÒÔ¼°×ÛºÏģʽ¡£ÄãÓ¦¸ÃÁ˽âUML£¬ÓÈÆäÊÇclass¡¢object¡¢interactionÒÔ¼°statediagrams¡£
2. ÄãÐèҪѧϰJavaÓïÑÔ ......

Effective Java¶ÁÊé±Ê¼Ç

package chape8;
/**
* µÚ8ÕÂ
* µÚ46條£º
* for-eachÑ­環優ÏÈÓÚforÑ­環
* for(Element e : c)
* {
* dosomthing(e);
* }
* Õâ¸öÊÇjava1.5ÒÔÉϵİ汾µÄforÑ­»·µÄÊ×ÏÈ¿¼ÂǵÄд·¨
* ÒÔÏÂÊÇjava1.5ÒÔÇ°µÄ寫·¨
*  for (Iterator it = c.iterator();it.hasNext();)
{ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ