在jdk的文件夹下面有一个src.zip

解决方案 »

  1.   

    package java.lang;import java.io.ObjectStreamClass;
    import java.io.ObjectStreamField;
    import java.io.UnsupportedEncodingException;
    import java.util.ArrayList;
    import java.util.Comparator;
    import java.util.Locale;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import java.util.regex.PatternSyntaxException;
    public final class String
        implements java.io.Serializable, Comparable, CharSequence
    {
        private char value[];    private int offset;    private int count;    private int hash = 0;
        private static final long serialVersionUID = -6849794470754667710L;    private static final ObjectStreamField[] serialPersistentFields =
            new ObjectStreamField[0];    public String() {
            value = new char[0];
        } 
        public String(String original) {
      this.count = original.count;
      if (original.value.length > this.count) {      this.value = new char[this.count];
          System.arraycopy(original.value, original.offset,
           this.value, 0, this.count);
      } else {      this.value = original.value;
      }
        }
        public String(char value[]) {
            this.count = value.length;
            this.value = new char[count];
            System.arraycopy(value, 0, this.value, 0, count);
        }    public String(char value[], int offset, int count) {
            if (offset < 0) {
                throw new StringIndexOutOfBoundsException(offset);
            }
            if (count < 0) {
                throw new StringIndexOutOfBoundsException(count);
            }
            if (offset > value.length - count) {
                throw new StringIndexOutOfBoundsException(offset + count);
            }        this.value = new char[count];
            this.count = count;
            System.arraycopy(value, offset, this.value, 0, count);
        }    public String(byte ascii[], int hibyte, int offset, int count) {
    checkBounds(ascii, offset, count);        char value[] = new char[count];
            this.count = count;
            this.value = value;        if (hibyte == 0) {
                for (int i = count ; i-- > 0 ;) {
                    value[i] = (char) (ascii[i + offset] & 0xff);
                }
            } else {
                hibyte <<= 8;
                for (int i = count ; i-- > 0 ;) {
                    value[i] = (char) (hibyte | (ascii[i + offset] & 0xff));
                }
            }
        }
        public String(byte ascii[], int hibyte) {
            this(ascii, hibyte, 0, ascii.length);
        }    private static void checkBounds(byte[] bytes, int offset, int length) {
    if (length < 0)
        throw new StringIndexOutOfBoundsException(length);
    if (offset < 0)
        throw new StringIndexOutOfBoundsException(offset);
    if (offset > bytes.length - length)
        throw new StringIndexOutOfBoundsException(offset + length);
        }
        public String(byte bytes[], int offset, int length, String charsetName)
    throws UnsupportedEncodingException
        {
    if (charsetName == null)
        throw new NullPointerException("charsetName");
    checkBounds(bytes, offset, length);
    value = StringCoding.decode(charsetName, bytes, offset, length);
    count = value.length;
        }
      

  2.   

    public String(byte bytes[], String charsetName)
    throws UnsupportedEncodingException
        {
    this(bytes, 0, bytes.length, charsetName);
        }    public String(byte bytes[], int offset, int length) {
    checkBounds(bytes, offset, length);
    value = StringCoding.decode(bytes, offset, length);
    count = value.length;
        }    public String(byte bytes[]) {
    this(bytes, 0, bytes.length);
        }    public String (StringBuffer buffer) {
            synchronized(buffer) {
                buffer.setShared();
                this.value = buffer.getValue();
                this.offset = 0;
                this.count = buffer.length();
            }
        }    String(int offset, int count, char value[]) {
    this.value = value;
    this.offset = offset;
    this.count = count;
        }    public char charAt(int index) {
            if ((index < 0) || (index >= count)) {
                throw new StringIndexOutOfBoundsException(index);
            }
            return value[index + offset];
        }    public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
            if (srcBegin < 0) {
                throw new StringIndexOutOfBoundsException(srcBegin);
            }
            if (srcEnd > count) {
                throw new StringIndexOutOfBoundsException(srcEnd);
            }
            if (srcBegin > srcEnd) {
                throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
            }
            System.arraycopy(value, offset + srcBegin, dst, dstBegin,
                 srcEnd - srcBegin);
        }    public void getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin) {
            if (srcBegin < 0) {
                throw new StringIndexOutOfBoundsException(srcBegin);
            }
            if (srcEnd > count) {
                throw new StringIndexOutOfBoundsException(srcEnd);
            }
            if (srcBegin > srcEnd) {
                throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
            }
            int j = dstBegin;
            int n = offset + srcEnd;
            int i = offset + srcBegin;
            char[] val = value;   /* avoid getfield opcode */        while (i < n) {
                dst[j++] = (byte)val[i++];
            }
        }    public byte[] getBytes(String charsetName)
    throws UnsupportedEncodingException
        {
    return StringCoding.encode(charsetName, value, offset, count);
        }太多了,拷不下来。
      

  3.   

    java.lang.String
    在jbuilder中
    search->find classes->java.lang.String
      

  4.   

    jdk中就有,其实我们没有必要去研究那个,直到怎么用就可以了
      

  5.   

    java.lang.String
    在jbuilder中
    search->find classes->java.lang.String
      

  6.   

    java.lang.Object是任何类的祖宗。
      

  7.   

    反编译一下java.lang中的String.class就能看到源码
      

  8.   

    楼上的各位都很强啊
    偶也只是好奇想要看看究竟
    怎么发现String类也是很复杂啊
    多谢 javafaq2004(又失业了) 考来的这么多
    偶也大概明白一些了
      

  9.   

    如果你用javareflection察看一个变量的类型的时候
    如果这个变量是int char byte short long float double boolean的话,它只会显示上述的名字,如果是其他的就会显示完整的类名比如java.lang.string
    和这些permitive变量相应的也有类,比如int->interger