码迷,mamicode.com
首页 > 编程语言 > 详细

Java Object类学习笔记

时间:2015-10-25 01:05:48      阅读:312      评论:0      收藏:0      [点我收藏+]

标签:


看下Api文档的一些说明

public class Object

Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.

    • Since:

    • JDK1.0 

从JDK1.0就已经存在的元老类,类结构的根,所有类的父类,所有类都实现了这个类的方法,包含arrays。特别强调了arrays。


Constructor Summary

Constructors  Constructor and Description 

Object()  

构造方法介绍。


Modifier and Type Method and Description 

protected Object clone() 

Creates and returns a copy of this object. 

clone方法,返回一个object对象的copy

boolean equals(Object obj) 

Indicates whether some other object is "equal to" this one. 

equals方法,属于最原始的equals,判断一个对象是否equal to另一个对象

protected void finalize() 

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. 

当确认这个对象没有任何的引用时,对一个对象调用大名鼎鼎的GC,垃圾收集器,

Class<?> getClass() 

Returns the runtime class of this Object. 

返回这个对象的运行时class

int hashCode() 

Returns a hash code value for the object. 

大名鼎鼎的hashcode方法,返回一个对象的hash code,注意是个整形int

void notify() 

Wakes up a single thread that is waiting on this object‘s monitor. 

wakes up一个正在等待当前对象的监视线程,一般翻译为唤醒线程

void notifyAll() 

Wakes up all threads that are waiting on this object‘s monitor. 

wakes up所有正在等待当前对象的监视线程,

String toString() 

Returns a string representation of the object. 

大名鼎鼎的toString()方法,返回对象的string 表示

void wait() 

Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object. 

大名鼎鼎的wait方法,面试经常会有人问他和sleep方法的区别。。,让当前线程等待,直到有别的线程调用该对象的notify()方法或者notifyAll()

void wait(long timeout) 

Causes the current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed. 

让当前线程等待另一个线程调用notify()方法或notifyAll()方法,或指定的时间运行。那么什么是指定时间运行?

void wait(long timeout, int nanos) 

Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed. 

让当前线程等待另一个线程调用notify()方法或notifyAll()方法,或者其他的线程中断当前线程,或指定的时间运行



Java Object类学习笔记

标签:

原文地址:http://my.oschina.net/weaver/blog/521668

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!