Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M Vidhun Kumar : [email protected] #117

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

vidhun88
Copy link

M Vidhun Kumar : [email protected]

Person class is imutable as both class and the class variable are final with no setter for the class asnd it has parameterised constructor which will be invoked only when object creation using new keyword, as constructors are called only when the object is initialised.
Above code is dependency injection(Constructor injection) as the object is passed as the time of initialization of the parent object which will in turn call constructor method and will get pass the object to the parent object.
equals and hashcode will ensure that the object reference is maintained based on the id and here the random generator is removed and the id.hashcode will pass the exact id which will return the same memeory reference for the each object with same id as the memory reference is replaced with same id by equals and hashcode implementation
Synchronised keyword and synchronised block is thread safe
private constructor will prevent object from initialization and hence the object will be initialized and will be obtained by the static method getInstance which initializes static variable if the same is null so the reference is maintained throughout the Application life cycle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant