<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Artem&#039;s blog &#187; continue</title>
	<atom:link href="http://artemgolubev.com/tag/continue/feed/" rel="self" type="application/rss+xml" />
	<link>http://artemgolubev.com</link>
	<description>Thoughts on software</description>
	<lastBuildDate>Tue, 20 Apr 2010 18:20:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Break and continue statements will stop exception flow</title>
		<link>http://artemgolubev.com/break-and-continue-statements-will-stop-exception-flow/</link>
		<comments>http://artemgolubev.com/break-and-continue-statements-will-stop-exception-flow/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 03:59:59 +0000</pubDate>
		<dc:creator>Artem</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[break]]></category>
		<category><![CDATA[continue]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java language specification]]></category>

		<guid isPermaLink="false">http://artemgolubev.com/break-and-continue-statements-will-stop-exception-flow/</guid>
		<description><![CDATA[As it is said in The Java Language Specification (http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.15):
&#8220;The preceding descriptions say &#8220;attempts to transfer control&#8221; rather than just &#8220;transfers control&#8221; because if there are any try statements within the break target whose try blocks contain the break statement, then any finally clauses of those try statements are executed, in order, innermost to outermost, [...]]]></description>
			<content:encoded><![CDATA[<p>As it is said in The Java Language Specification (<a href="http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.15"><font color="#5588aa">http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.15</font></a>):<br />
&#8220;<span style="font-style: italic">The preceding descriptions say &#8220;attempts to transfer control&#8221; rather than just &#8220;transfers control&#8221; because if there are any </span><code style="font-style: italic">try</code><span style="font-style: italic"> statements </span><span style="font-style: italic">within the break target whose </span><code style="font-style: italic">try</code><span style="font-style: italic"> blocks contain the </span><code style="font-style: italic">break</code><span style="font-style: italic"> statement, then any </span><code style="font-style: italic">finally</code><span style="font-style: italic"> clauses of those </span><code style="font-style: italic">try</code><span style="font-style: italic"> statements are executed, in order, innermost to outermost, before control is transferred to the break target. Abrupt completion of a </span><code style="font-style: italic">finally</code><span style="font-style: italic"> clause can disrupt the transfer of control initiated by a </span><code style="font-style: italic">break</code><span style="font-style: italic"> statement.</span>&#8221;<br />
Let&#8217;s look into next example:</p>
<pre>
public class Test {
	private static void test() throws Exception {
		for (int i = 0; i &lt; 3; i++) {
			try {
				throw new Exception("Exception text");
			} finally {
				System.out.println("Finally exception " + i);
				continue;
			}
		}
		System.out.println("Impossible");
	}

	public static void main(String[] args) throws Exception {
		test();
		System.out.println("Impossible 2");
	}
}</pre>
<p>will produce output:<br />
<code><br />
Finally exception 0<br />
Finally exception 1<br />
Finally exception 2<br />
Impossible<br />
Impossible 2<br />
</code></p>
<p>So, be extremely careful with your breaks!</p>
]]></content:encoded>
			<wfw:commentRss>http://artemgolubev.com/break-and-continue-statements-will-stop-exception-flow/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
