1.The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
2.String
Note that none of the parameters is a String so conversion to String will not happen. It will try to convert every thing to an int and you will get :
Incompatible type for +. Can't convert null to int.
System.out.println( null + null);
^
Here are the rules for String conversion:
If only one operand expression is of type String, then string conversion is performed on the other operand to produce a string at run time. The result is a reference to a newly created String object that is the concatenation of the two operand strings. The characters of the left-hand operand precede the characters of the right-hand operand in the newly created string.
Any type may be converted to type String by string conversion.
A value x of primitive type T is first converted to a reference value as if by giving it as an argument to an appropriate class instance creation expression: For eg. if T is boolean, then use new Boolean(x) .
This reference value is then converted to type String by string conversion.
Now only reference values need to be considered. If the reference is null, it is converted to the string "null" (four ASCII characters n, u, l, l). Otherwise, the conversion is performed as if by an invocation of the toString method of the referenced
object with no arguments; but if the result of invoking the toString method is null, then the string "null" is used instead. The toString method is defined by the primordial class Object; many classes override it, notably Boolean, Character, Integer,
Long, Float, Double, and String.
Note that, had there been a method like String getString() { return null; }, println( getString() + true ) etc. would have compiled fine and would have printed "nulltrue".
3. string method
int indexOf(str,fromIndex) // Index form 0
str.substring(fromIndex,toIndex) //Index from 1 and fromIndex <range <=toIndex
4. i *= (int) Math. round(d-6); => i = 12 * (-2). Rule for rounding is Truncate( i + 0.5) => truncate (-2.5 +.5) = truncate(-2.0) = -2
5 AVI Study
5.1.String 雖然是引用類型但是是final的,所以不會在方法中改動
5.2.簡型在方法中改動候,外面不變
5.3.引用類型經過方法修改候,外面的值變化了
5.4.如果需要改變String ,可以把類A實現Cloneable(標誌接口,表示實現該接口的類可以克隆了),并override clone(),在修改克隆A中String 變量的內容,而不影響到A中String
5.4.1 ,需要注意如果實現Cloneable的類A中有依賴另一個類B ,如果B沒有實現Cloneable,那麼在克隆A時,A中依賴的B的內容是不會被克隆(),修改A的克隆對象中的B會一并修改了A的B
5.5 基本類型,包裝類,和String 之間轉換的方法
5.6.java.lang.System
arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
5.7.java.lang.Class
5.7.1 forName(String className)
5.7.2 ClassName.class
5.7.3 getClasses()
如果動態的到Class
5.7.4 newInstance() class 是一個缺省構造函數的類,需要通過其中的getDeclaredConstructor(Class[] parameterTypes)等方法 來取得動態的Class中的java.lang.reflect中的類 Constructor,Field,Method,Modifier
getClass().getName() + '@' + Integer.toHexString(hashCode())
2.String
Note that none of the parameters is a String so conversion to String will not happen. It will try to convert every thing to an int and you will get :
Incompatible type for +. Can't convert null to int.
System.out.println( null + null);
^
Here are the rules for String conversion:
If only one operand expression is of type String, then string conversion is performed on the other operand to produce a string at run time. The result is a reference to a newly created String object that is the concatenation of the two operand strings. The characters of the left-hand operand precede the characters of the right-hand operand in the newly created string.
Any type may be converted to type String by string conversion.
A value x of primitive type T is first converted to a reference value as if by giving it as an argument to an appropriate class instance creation expression: For eg. if T is boolean, then use new Boolean(x) .
This reference value is then converted to type String by string conversion.
Now only reference values need to be considered. If the reference is null, it is converted to the string "null" (four ASCII characters n, u, l, l). Otherwise, the conversion is performed as if by an invocation of the toString method of the referenced
object with no arguments; but if the result of invoking the toString method is null, then the string "null" is used instead. The toString method is defined by the primordial class Object; many classes override it, notably Boolean, Character, Integer,
Long, Float, Double, and String.
Note that, had there been a method like String getString() { return null; }, println( getString() + true ) etc. would have compiled fine and would have printed "nulltrue".
3. string method
int indexOf(str,fromIndex) // Index form 0
str.substring(fromIndex,toIndex) //Index from 1 and fromIndex <range <=toIndex
4. i *= (int) Math. round(d-6); => i = 12 * (-2). Rule for rounding is Truncate( i + 0.5) => truncate (-2.5 +.5) = truncate(-2.0) = -2
5 AVI Study
5.1.String 雖然是引用類型但是是final的,所以不會在方法中改動
5.2.簡型在方法中改動候,外面不變
5.3.引用類型經過方法修改候,外面的值變化了
5.4.如果需要改變String ,可以把類A實現Cloneable(標誌接口,表示實現該接口的類可以克隆了),并override clone(),在修改克隆A中String 變量的內容,而不影響到A中String
5.4.1 ,需要注意如果實現Cloneable的類A中有依賴另一個類B ,如果B沒有實現Cloneable,那麼在克隆A時,A中依賴的B的內容是不會被克隆(),修改A的克隆對象中的B會一并修改了A的B
5.5 基本類型,包裝類,和String 之間轉換的方法
5.6.java.lang.System
arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
5.7.java.lang.Class
5.7.1 forName(String className)
5.7.2 ClassName.class
5.7.3 getClasses()
如果動態的到Class
5.7.4 newInstance() class 是一個缺省構造函數的類,需要通過其中的getDeclaredConstructor(Class[] parameterTypes)等方法 來取得動態的Class中的java.lang.reflect中的類 Constructor,Field,Method,Modifier