G.5 Class Object

As we discussed earlier in this appendix, all classes in Java inherit directly or indirectly from the Object class (package java.lang), so its 11 methods (some are overloaded) are inherited by all other classes. Figure G.12 summarizes Object’s methods. We discuss several Object methods throughout this book (as indicated in Fig. G.12).

Fig. G.12 Object methods

Method Description
clone This protected method, which takes no arguments and returns an Object reference, makes a copy of the object on which it’s called. The default implementation performs a so-called shallow copy—instance-variable values in one object are copied into another object of the same type. For reference types, only the references are copied. A typical ...

Get Android How to Program, 3/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.