foreach loop a java creation?

前端 未结 5 2099
粉色の甜心
粉色の甜心 2020-12-21 18:34

Why was this loop introduced in java?Is it a java creation? What is its purpose(increases memory/cpu utilisation efficiency)?

5条回答
  •  青春惊慌失措
    2020-12-21 19:11

    It masks the use of iterators, which are heavy and clumsy to use. There are many, many instances where you just want to iterate over a collection without working about its index. The java foreach structure makes this possible.

提交回复
热议问题