java tricky one!

Associate
Joined
26 Jan 2006
Posts
1,502
Hey,

I wonder in what order the following is executed.

Assume there is a vector v passed an argument to a method which has the following:

Code:
try{ return v.remove(0); } finally { updateGui(gui); }

The question is, does the element FIRST get removed from the vector and THEN the gui will be updated?

thanks
 
Yes, the gui update relies on the element getting removed. The gui traverses the vector and draws the objects found, therefore it should ALWAYS happen after the removal.

I just like the "less code idea", but it can be done with
Code:
Object obj = v.remove(0); updateGui(gui); return obj;
I guess to avoid confusion and hackery :p

Just was not sure how exactly the finally clause works :)
 
Back
Top Bottom