java-se object

来源:互联网 发布:java ssh jar 编辑:程序博客网 时间:2024/04/25 22:42

object 是 java 基类;

object 有clone, hashcode,equals,notify,notifyall, wait 等方法

以下 讨论默认提供的方法,重写的方法 pass;

clone :a native function,u can't use directly;direct use will clone a object from super class; and throw out CloneNotSupportedException

u need  implements Clonenable interface, it will be work fine;

hashcode : default return is memory address;

collection applying this feature, to store the elements;first calculate hash-code and set it to the addr(hash-code address);

 equals: checking object address whether equal;(== is checking param equal and equals func is checking object )

more simply -> equals compare the object contents , == compare object memory address;


the relation between hashcode and equals;

if 2 object equals it has same hashcode;

if 2 object not equals it is also can have same hashcode (case: hash conflict)


wait,notify,notifyall :thread operating function, wait will give up the thread lock,

 



原创粉丝点击