public String(String original) {
this.value = original.value;
this.hash = original.hash;
}
I dont understand how original is being converted to a char array. If i try it with a different code, its throwing a compilation error.
解决方案
String has two properties:
/** The value is used for character storage. */
private final char value[];
/** Cache the hash code for the string */
private int hash; // Default to 0
Because you're inside the constructor of String, you have access right to its private field value[] and hash.
You cann't access those private fields from outside of String class, hence it will throw a compilation error if you attempt to do it.