M
M
Murad Murtuzaliev2022-03-16 17:25:29
Java
Murad Murtuzaliev, 2022-03-16 17:25:29

How many times will the memory be allocated?

Will the memory for the array be allocated at each iteration of the loop?

for (SomeClass obj : new SomeClass[]{ obj1, obj2, obj3 }) {
    // code
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2022-03-16
@ordinary_programmer

Of course not, the array is created when the loop is initialized.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question