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

item11.71p 코드 11-4에서 해시코드를 지연초기화 전략을 활용해서 구현해야 하는 이유? #13

Closed
polarHub25 opened this issue Apr 11, 2024 · 3 comments

Comments

@polarHub25
Copy link
Owner

코드 11-4 에 해시코드를 지연 초기화하는 전략으로 작성한 해시코드 메서드가 있는데, 왜 지연초기화를 해서 구현을 해야하는지에 대해서 토론 해보고싶습니다..!

@donghyeon3813
Copy link
Collaborator

객체를 초기화할 때 hashCode가 필요하지 않은 상황에도 초기화를 하게 되면 자원의 낭비가 이루어집니다.
더군다나 hashcode를 초기화하는 비용 자체도 높다면 그 낭비가 더욱 심해지기 때문에 지연 초기화 전략을 구사하려는 것 같아요

@polarHub25
Copy link
Owner Author

그러면 필요할때만 해시코드 메서드를 호출하면 되지않나요??

@polarHub25
Copy link
Owner Author

지연초기화 라는 개념 자체를 제가 잘못 이해하고 있던거같습니다. 결국 필요할때 호출되서 사용할수있도록 하는게 지연초기화라는 개념이라는것을 이해했습니다. !

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

No branches or pull requests

2 participants