[quote=“Cres, post:1, topic:555083”]what’s the difference between
Rectangle search;
for (Client c : clients) {
search = new Rectangle();
//do the updating
}
and
for (Client c : clients) {
Rectangle search = new Rectangle();
//do the updating
}
been wondering if this does anything performance wise for a long while now[/quote]
I might be completely wrong here, so please correct me if I am.
- I do realise the compiler optimises both samples to about the same bytecode
But doesn’t the first statement (Rectangle search;) find free space on the machine, which it keeps occupied for data which will eventually get allocated to it (search = new Rectangle();)?
So the loop would just assign different data to the occupied space on the machine each time?
This whilst the second sample searches for free space on the machine to allocate the data to, each single iteration?