What is the best approach of writing java code in following 2...... ? What happens at jvm level in each case ?
1.
for(int i=0;i<10;i++)
{
MyClass m = new MyClass();
m.doSomething();
}
2.
MyClass m;
for(int i=0;i<10;i++)
{
m = new MyClass();
m.doSomething();
}