Why does break in a for loop not work when finally is involved
Nils Andresen <nils-AVNmLDg75hOg/[email protected]> Thu, 21 Jun 2012 10:03:06 +0200
| Newsgroups | gmane.comp.java.beanshell.user |
|---|---|
| Message-ID | <CACKUC=6iBKCS+ha9xWB_TChwuz05S5DFk-F8mAg868_SmfQ8Jg@mail.gmail.com> |
Hi,
The following code:
print(" - Start");
int[] num = new int[] {1,2,3,4,5,6,7,8,9,10};
for(int i : num)
{
print("--> "+ i);
try
{
Print(" . try");
if(i == 2)
break;
}
catch (java.lang.Exception e)
{}
finally
{
print(" . finally");
}
}
print(" - End");
does not break as expected but runs all 10 iterations. If I remove the
finally block everything works as expected. Can someone tell me why
this is?
Best,
Nils
P.S.
I posted this question at [1] but it seems there are not so many
beanshell users at stackoverflow...
1: http://stackoverflow.com/questions/11113948/why-does-break-in-a-for-loop-not-work-when-finally-is-involved-in-beanshell
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/