문제

Why does the course at Stanford use the lazy initialization for all getters?

Is this correct? Does it have any real advantage?

One advantage (for me) is that the init method can become much shorter and you need not check if a variable is allocated.

올바른 솔루션이 없습니다

다른 팁

The idea is to load resources on demand. This way everything loads faster and when needed. In the cases it's not used, it doesn't allocate additional memory.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top