In addition, in your example, when the cycle loop ends for, the reference to this object is lost, because the area in which they were created remains. Without referring to objects, a garbage collector appears and frees this memory by deleting objects.
, . , , :
GridView view;
for(int i =1; i<5; i++){
view = new Gridview(this);
}
, , . .
, , : , , - . .
. , ( ), . , Java, PHP:
class Object {
function hello(){
echo "Hello \n";
}
}
for($i =1; $i<5; $i++){
$name = "view".$i;
$$name = new Object();
}
$view1->hello();
$view2->hello();
$view4->hello();
: http://codepad.org/bFqJggG0