Skip to content
This repository was archived by the owner on Sep 2, 2023. It is now read-only.

Latest commit

 

History

History
5 lines (3 loc) · 410 Bytes

File metadata and controls

5 lines (3 loc) · 410 Bytes
  • foreach 문의 정식 이름은 향상된 for문 이다.
  • foreach문은 컬렉션과 배열은 물론 Iterable 인터페이스를 구현한 객체라면 무엇이든 순회할 수 있다.

전통적인 for문과 비교했을 때 for-each 문은 명료하고, 유연하고, 버그를 예방해준다. 성능 저하도 없다. 가능한 모든 곳에서 for문이 아닌 for-each문을 사용하자.