Could you explain to me which code is better (more optimal) and why?
Vesion 1:
while(something){
Runnable task = (Runnable) taskQueue.dequeue();
Throwable ex = null;
...
}
Version 2:
Runnable task;
Throwable ex;
while(something){
task = (Runnable) taskQueue.dequeue();
ex = null;
...
}
For me it looks like second version is optimized because variable declaration is out of while loop.