P
Philipp
Hello
Just wondering, is there a speed or memory difference between the two
following codes? What is recommended? Which will easier garbage collect
(suppose MyClass is big)?
--- code ---
for(int i = 0; i < 1000; i++){
MyClass mine = new MyClass();
mine.doSomething();
}
------------
and
--- code ---
MyClass mine;
for(int i = 0; i < 1000; i++){
mine = new MyClass();
mine.doSomething();
}
Just wondering, is there a speed or memory difference between the two
following codes? What is recommended? Which will easier garbage collect
(suppose MyClass is big)?
--- code ---
for(int i = 0; i < 1000; i++){
MyClass mine = new MyClass();
mine.doSomething();
}
------------
and
--- code ---
MyClass mine;
for(int i = 0; i < 1000; i++){
mine = new MyClass();
mine.doSomething();
}