JAVAÖÐÓÃÓÚ´¦Àí×Ö·û´®µÄ¡°ÈýÐֵܡ±
JAVAÖÐÓÃÓÚ´¦Àí×Ö·û´®µÄ“ÈýÐֵܔ
JAVAÖÐÓÃÓÚ´¦Àí×Ö·û´®³£ÓõÄÓÐÈý¸öÀࣺjava.lang.String¡¢java.lang.StringBuffer¡¢java.lang.StringBuilder£¬ÕâÈýÕߵĹ²Í¬Ö®´¦¶¼ÊÇfinalÀ࣬²»ÔÊÐí±»¼Ì³Ð£¬ÕâÖ÷ÒªÊÇ´ÓÐÔÄܺͰ²È«ÐÔÉÏ¿¼Âǵģ¬ÒòΪÕ⼸¸öÀ඼ÊǾ³£±»Ê¹ÓÃ×ŵģ¬ÇÒ¿¼Âǵ½·ÀÖ¹ÆäÖеIJÎÊý±»ÐÞ¸ÄÓ°Ïìµ½ÆäËüµÄÓ¦Óá£StringBufferÓëStringBuilderÁ½¸ö»ù±¾Éϲ¶à£¬Ö»ÊÇStringBufferÊÇḬ̈߳²È«£¬¿ÉÒÔ²»ÐèÒª¶îÍâµÄͬ²½ÓÃÓÚ¶àÏß³ÌÖУ»StringBuilderÊÇ·Çͬ²½£¬ÔËÐÐÓÚ¶àÏß³ÌÖоÍÐèҪʹÓÃ×ŵ¥¶Àͬ²½´¦Àí£¬µ«ÊÇËٶȾͱÈStringBuffer¿ì¶àÁË£»¶þÕßÖ®¼äµÄ¹²Í¬µã¶¼¿ÉÒÔͨ¹ýappend¡¢insert½øÐÐ×Ö·û´®µÄ²Ù×÷¡£
StringʵÏÖÁËÈý¸ö½Ó¿Ú£ºSerializable¡¢Comparable<String>¡¢CharSequence£¬¶øStringBuffer¼°StringBuilderֻʵÏÖÁËÁ½¸ö½Ó¿ÚSerializable¡¢CharSequence£¬Ïà±ÈÖ®ÏÂStringµÄʵÀý¿ÉÒÔͨ¹ýcompareTo·½·¨½øÐбȽϣ¬¶øÆäËüÁ½¸ö¾Í²»¿ÉÒÔ¡£
ÒÔÏÂÊÇJDKÖжÔString¡¢StringBuffer¡¢StringBuilderµÄÏêϸ½éÉÜ£º
String£º
String Àà´ú±í×Ö·û´®¡£Java ³ÌÐòÖеÄËùÓÐ×Ö·û´®×ÖÃæÖµ£¨Èç "abc" £©¶¼×÷Ϊ´ËÀàµÄʵÀýʵÏÖ¡£
×Ö·û´®Êdz£Á¿£»ËüÃǵÄÖµÔÚ´´½¨Ö®ºó²»Äܸü¸Ä¡£×Ö·û´®»º³åÇøÖ§³Ö¿É±äµÄ×Ö·û´®¡£ÒòΪ String ¶ÔÏóÊDz»¿É±äµÄ£¬ËùÒÔ¿ÉÒÔ¹²Ïí¡£ÀýÈ磺
String str = "abc";
µÈЧÓÚ£º
char data[] = {'a', 'b', 'c'};
String str = new String(data);
ÏÂÃæ¸ø³öÁËһЩÈçºÎʹÓÃ×Ö·û´®µÄ¸ü¶àʾÀý£º
System.out.println("abc");
String cde = "cde";
System.out.println("abc" + cde);
String c = "abc".substring(2,3);
String d = cde.substring(1, 2);
String Àà°üÀ¨µÄ·½·¨¿ÉÓÃÓÚ¼ì²éÐòÁеĵ¥¸ö×Ö·û¡¢±È½Ï×Ö·û´®¡¢ËÑË÷×Ö·û´®¡¢ÌáÈ¡×Ó×Ö·û´®¡¢´´½¨×Ö·û´®¸±±¾²¢½«ËùÓÐ×Ö·ûÈ«²¿×ª»»Îª´óд»òСд¡£´óСдӳÉä»ùÓÚ Character ÀàÖ¸¶¨µÄ Unicode ±ê×¼°æ¡£
Java ÓïÑÔÌṩ¶Ô×Ö·û´®´®Áª·ûºÅ£¨"+"£©ÒÔ¼°½«ÆäËû¶ÔÏóת»»Îª×Ö·û´®µÄÌØÊâÖ§³Ö¡£×Ö·û´®´®ÁªÊÇͨ¹ý StringBuilder£¨»ò StringBuffer£©À༰Æä append ·½·¨ÊµÏֵġ£×Ö·û´®×ª»»ÊÇͨ¹ý toString ·½·¨ÊµÏֵģ¬¸Ã·½·¨ÓÉ Object ÀඨÒ壬²¢¿É±» Java ÖеÄËùÓÐÀà¼Ì³Ð¡£Óй
Ïà¹ØÎĵµ£º
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.io.Reader;
public class ReadfromFile{
/**
......
2006ÄêÎÒÔø¾Ð´¹ýһƪÌÖÂÛJavaδÀ´µÄÎÄÕ£¬ÔÚÄÇƪÎÄÕÂÖÐÎÒÌÖÂÛÁË¿ªÔ´¡¢JavaÔÚÏû·Ñµç×ÓÉ豸ÖеÄʹÓã¬ÏÖÔÚÔÚËùÓÐÀàÐ͵ÄÒƶ¯É豸ÉÏJavaµÄÓ¦ÓÃÕýÔÚÖð²½ÉÏÉý¡£¶ÔSun±»ÊÕ¹ºÒ»Ê£¬ÒÔ¼°JavaÓëOracle²úÆ·¼¯³ÉÎÒûʲôºÃÔ¤²âµÄ£¬Ò²Ã»Ê²Ã´ºÃµÄ½¨Ò飬ÎÒÖ»µ£ÐÄJavaµÄδÀ´»á×ßÏòºÎ·½?ÔÚÕâƪÎÄÕÂÖÐÎÒÖØÐÂÉóÊÓÁËOracleÊÕ¹ºSunºóJavaµÄδÀ´Ö ......
ÔÚ×ö¹ýÒ»Äê¶àµÄRXTX²Ù×÷´®¿ÚÏîÄ¿ÓÐÏÖÔÚ°ÑһЩƽʱÓöµ½µÄÎÊÌâÔÚÕâÀïдд£º
RXTXÊÇÒ»¸ö¿ªÔ´°ü£¬Ö÷ÒªÊÇÔÚCOMM¿ªÔ´°üÖÐ×öÀ©ÕÅ£¬ÒÔÇ°µÄCOMM°üÖ»ÄÜÔÚWINDOWSÏÂÃæ¶Ô´®¿Ú»ò²¢¿Ú×ö²Ù×÷£¬À©³äºóµÄRXTX¿ÉÒÔÔÚLINUXºÍMAC϶Դ®¿ÚºÍ²¢¿Ú×ö²Ù×÷¡£ ÏÖÔÚ¿çƽ̨£º
ÔÚRXTXÍøÕ¾ÏÂÔØJAR°üºÍ¶¯Ì¬¿â
http://users.frii.com/jarvi/rxtx ......
ÎļþÃû£ºSjis.java
class Sj
{
public static void main(String[] args)
{
}
}
-------------------------------------
Ö´ÐУº
javac Sjis.java
Java Sj
¡¢¡¢¡¢¡¢¡¢¡¢¡¢¡¢¡¢¡¢¡¢¡¢¡¢¡¢¡¢¡¢¡¢
ÎļþÃû£ºSjis.java
public class Sjis.java
{
public static ......
JAVAÖÐÓÃÓÚ´¦Àí×Ö·û´®µÄ“ÈýÐֵܔ
JAVAÖÐÓÃÓÚ´¦Àí×Ö·û´®³£ÓõÄÓÐÈý¸öÀࣺjava.lang.String¡¢java.lang.StringBuffer¡¢java.lang.StringBuilder£¬ÕâÈýÕߵĹ²Í¬Ö®´¦¶¼ÊÇfinalÀ࣬²»ÔÊÐí±»¼Ì³Ð£¬ÕâÖ÷ÒªÊÇ´ÓÐÔÄܺͰ²È«ÐÔÉÏ¿¼Âǵģ¬ÒòΪÕ⼸¸öÀ඼ÊǾ³£±»Ê¹ÓÃ×ŵģ¬ÇÒ¿¼Âǵ½·ÀÖ¹ÆäÖеIJÎÊý±»ÐÞ¸ÄÓ°Ïìµ½ÆäËüµÄÓ¦Óᣠ......