A very basic question:
//List<Students> b;
for(int i=0;i<count;i++){
List<Students> b = school.getstudents(classID);
}
Although it is recommended to keep the scoping as small as possible,is there any advantage of a outer scope variable when we are looping through a possibly unbounded counter.
Is there any difference in the instances created and promoted from the young generation by either of the approaches?
To be more specific, in case we are looping through a count on a million students - would we be reducing the possibility of higher object promotions and full GC if we declared the variable outside