8.java.lang Package

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Internal Error occurred. java.lang.SecurityException: Prohibited package name: java.com.lsm.testrocketmq at java.base/java.lang.ClassLoader.preDefineClass(ClassLoader.java:898) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1014) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:315) at com.intellij.junit5.JUnit5TestRunnerUtil.loadMethodByReflection(JUnit5TestRunnerUtil.java:124) at com.intellij.junit5.JUnit5TestRunnerUtil.buildRequest(JUnit5TestRunnerUtil.java:100) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:43) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
最新发布
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值