문제

Why do you need to add the keyword void before certain methods. I know it means the method returns nothing (or at least that's what I think it means), but why should you add void even if you already know the method is supposed to return nothing?

도움이 되었습니까?

해결책

To tell the compiler that the method is supposed to return nothing.

This kind of redundancy allows the compiler to tell you if you make a mistake somewhere.
(eg, forgetting a return statement)

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