Home > Programming > Java Programming
Effective Java(TM) Programming Language Guide
Sort Desciption:Perhaps a later release of the Java platform will provide stateof. theart hash functions for its classes and utility methods to allow average program ...
Content Inside:Effective Java(TM) Programming Language GuidePage 125C H A P T E R3Methods Common to All ObjectsALTHOUGHObjectis a concrete class it is designed primarily for extension. Allof its nonfinal methods (equals hashCode toString clone andfinalize) haveexplicit general contracts because they are designed to be overridden. It is theresponsibility of any class overriding these methods to obey their general contracts; failure to do so will prevent other classes that depend on these contractsfrom functioning properly in conjunction with the class.This chapter tells you when and how to override the nonfinalObjectmethods.Thefinalizemethod is omitted from this chapter because it was discussed inItem 6. While not anObjectmethodComparable.compareTois discussed in thischapter because it has a similar character.Item 7: Obey the general contract when overridingequalsOverriding the equalsmethod seems simple but there are many ways to get itwrong and the consequences can be dire. The easiest way to avoid problems is notto override theequalsmethod in which case each instance is equal only to itself.This is the right thing to do if any of the following conditions apply: Each instance of the class is inherently unique. This is true for classes thatrepresent active entities rather than values such asThread. Theequalsimplementation provided by Objecthas exactly the right behavior for these classes. You dont care whether the class provides a logical equality test. Forexamplejava.util.Randomcould have overridden equalsto check whethertwo Randominstances would produce the same sequence of random numbersgoing forward but the designers didnt think that clients would need or wantthis functionality. Under these circumstances theequalsimplementationinherited fromObjectis adequate.Page 2CHAPTER 3 METHODS COMMON TO ALL OBJECTS26 A superclass has already overriddenequalsand the behavior inheritedfrom the superclass is appropriate for this class. For example mostSetimplementations inherit theirequals ...
Source: www.tel.fer.hr
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Related Files
<>An Introduction to Java Programming
Filed under: Programming and Java ProgrammingType java Welcome to run the program. A sample run of ... You can run the Java program from the DOS prompt using. the java command. ...
Java Server Programming: Principles and Technologies
Filed under: Programming and Java Programminglargescale serverside applications using the Java programming language. ... Professional java server programming J2EE edition. Wrox Press Inc. ...
Java Programming Language SL275
Filed under: Programming and Java Programminglanguage; objectoriented programming. with the Java programming language; and ... SL275: Java Programming Language. 2 of 5. Sun Educational Services ...
Java 2 Enterprise Edition (J2EE) Certificate Program
Filed under: Programming and Java Programmingthat are available with the Java programming language. and development environment. .... database tasks and transactions from a Java program. ...
Programming mobile devices with J2ME
Filed under: Programming and Java ProgrammingJava's interfaces, with the possibility of using a layer programming structure in ... For example the access to a built-in camera in a mobile phone by means of ...
