Declaring outside a loop: speed? memory?



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();
}
------------


Thanks for your answers
Phil
.



Relevant Pages

  • Re: Synchronized block is accessed by other jsps
    ... This is my code in jsp file. ... MyClass myClass = new MyClass; ... some codes here ... Is the 2nd method correct way of synchronizing a method to access in ...
    (comp.lang.java.programmer)
  • Re: Object Instantiation check ...HOW
    ... or codes to be followed. ... MyClass CreateNewInstance ... MyClass ret = new MyClass; ... (Note that this isn't thread-safe - if you need to do this from multiple threads, ...
    (microsoft.public.dotnet.languages.csharp)