Java中的String常量剖析(ZZ)
摘要: 常量池(constant pool)指的是在編譯期被確定,并被保存在已編譯的.class文件中的一些數據。它包括了關于類、方法、接口等中的常量,也包括字符串常量。
閱讀全文
posted @
2010-08-28 17:44 waynewan 閱讀(340) |
評論 (0) 編輯
java中的clone
摘要: Suppose you have an object ‘a’ of class ‘A’. Sometimes you may need another new object ‘b’. It also belongs to class ‘A’ and has the same data with object ‘a’. But if you do some modification on b, it has no effect to the value of ‘a’. We call this process which produced new object ‘b’ as clone object ‘a’. The commonest time that you need to clone an object is when it is a parameter or return value of one of your public methods. If it is a parameter that you save somewhere, then you don't want t
閱讀全文
posted @
2010-08-28 17:36 waynewan 閱讀(289) |
評論 (0) 編輯
Java中的Clone剖析(ZZ)
摘要: Java語言的一個優點就是取消了指針的概念,但也導致了許多程序員在編程中常常忽略了對象與引用(此引用非C++中的引用)的區別,特別是先學c、c++后學java的程序員。并且由于Java不能通過簡單的賦值來解決對象復制的問題,在開發過程中,也常常要要應用clone()方法來復制對象。比如函數參數類型是自定義的類時,此時便是引用傳遞而不是值傳遞。
閱讀全文
posted @
2010-08-28 17:21 waynewan 閱讀(331) |
評論 (0) 編輯