<?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>for-loop Archives - SoftUni Global</title>
	<atom:link href="https://softuni.org/tag/for-loop/feed/" rel="self" type="application/rss+xml" />
	<link>https://softuni.org/tag/for-loop/</link>
	<description>Learn Programming and Start a Developer Job</description>
	<lastBuildDate>Fri, 13 May 2022 11:36:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://softuni.org/wp-content/uploads/2022/04/cropped-SoftUni-Global-Logo-Square-notext-32x32.png</url>
	<title>for-loop Archives - SoftUni Global</title>
	<link>https://softuni.org/tag/for-loop/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Java Basics Tutorial &#8211; Part 7 &#8211; For Loops</title>
		<link>https://softuni.org/code-lessons/java-basics-tutorial-part-7-for-loops/</link>
					<comments>https://softuni.org/code-lessons/java-basics-tutorial-part-7-for-loops/#respond</comments>
		
		<dc:creator><![CDATA[Aleksandar Peev]]></dc:creator>
		<pubDate>Sat, 23 Oct 2021 11:06:00 +0000</pubDate>
				<category><![CDATA[Code Lessons]]></category>
		<category><![CDATA[Java Basics Free Course]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[code lessons]]></category>
		<category><![CDATA[for-loop]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java-tutorial]]></category>
		<category><![CDATA[javabasics]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">https://softuni.org/?p=10039</guid>

					<description><![CDATA[<p>In this lesson of the Java Basics Tutorial, we take a look at For Loops.</p>
<p>The post <a href="https://softuni.org/code-lessons/java-basics-tutorial-part-7-for-loops/">Java Basics Tutorial &#8211; Part 7 &#8211; For Loops</a> appeared first on <a href="https://softuni.org">SoftUni Global</a>.</p>
]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="10039" class="elementor elementor-10039" data-elementor-post-type="post">
						<section class="elementor-section elementor-top-section elementor-element elementor-element-5d5405e elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="5d5405e" data-element_type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-0d32134" data-id="0d32134" data-element_type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-9216798 elementor-widget elementor-widget-text-editor" data-id="9216798" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p><span data-preserver-spaces="true">In programming, a loop is used to repeat a block of code until a specified condition is met. The<strong> For Loop</strong> is best when you want to do something for a fixed number of times.</span></p><p><span data-preserver-spaces="true"><img fetchpriority="high" decoding="async" class="size-medium wp-image-10515 alignright" src="https://softuni.org/wp-content/uploads/2022/01/for-loop-diagram-214x300.jpg" alt="" width="214" height="300" srcset="https://softuni.org/wp-content/uploads/2022/01/for-loop-diagram-214x300.jpg 214w, https://softuni.org/wp-content/uploads/2022/01/for-loop-diagram.jpg 340w" sizes="(max-width: 214px) 100vw, 214px" />How does <strong>For Loop</strong> work?</span></p><ol><li>Control falls into the <strong>For Loop</strong>. <strong>Initialization</strong> is done.</li><li>The flow jumps to the <strong>Condition.</strong></li><li>The <strong>Condition</strong> is tested.<ol><li>If it is <strong>true</strong>, the flow goes into the body.</li><li>If it is <strong>false</strong>, the flow goes outside the loop.</li></ol></li><li>The statements inside the body of the loop get executed.</li><li>The <strong>update</strong> takes place, and the flow goes to Step 3 again.</li><li>The <strong>For Loop</strong> has ended, and the flow has gone outside.</li></ol><p><span data-preserver-spaces="true">This process goes on until the test expression is <strong>false</strong>. When the test expression is <strong>false</strong>, the loop terminates.</span></p><p style="text-align: justify;">Say we want to loop over a range of numbers and print out each one along the way. We can do this best with a <strong>For Loop</strong>. We will start from the first number, print it out, move to the next number to do the same thing, and continue until we’ve printed each number. Let’s print the numbers zero through nine:</p><p style="text-align: center;"><img decoding="async" class="alignnone size-medium wp-image-10516" src="https://softuni.org/wp-content/uploads/2022/01/for-loop-example-2-300x75.png" alt="" width="300" height="75" srcset="https://softuni.org/wp-content/uploads/2022/01/for-loop-example-2-300x75.png 300w, https://softuni.org/wp-content/uploads/2022/01/for-loop-example-2.png 323w" sizes="(max-width: 300px) 100vw, 300px" /></p><p>Let’s look at the first line of the <strong>For Loop</strong> and the three parts necessary to make it work. First, we have an<strong> initialization</strong> expression, then <strong>termination</strong> expression, and <strong>increment</strong> expression in the end.</p><p><img decoding="async" class=" wp-image-10518 alignright" src="https://softuni.org/wp-content/uploads/2022/01/for-loop-picture-300x143.png" alt="" width="342" height="163" srcset="https://softuni.org/wp-content/uploads/2022/01/for-loop-picture-300x143.png 300w, https://softuni.org/wp-content/uploads/2022/01/for-loop-picture-600x285.png 600w, https://softuni.org/wp-content/uploads/2022/01/for-loop-picture-1024x486.png 1024w, https://softuni.org/wp-content/uploads/2022/01/for-loop-picture-768x365.png 768w, https://softuni.org/wp-content/uploads/2022/01/for-loop-picture-1536x730.png 1536w, https://softuni.org/wp-content/uploads/2022/01/for-loop-picture.png 1825w" sizes="(max-width: 342px) 100vw, 342px" />The <strong>initialization</strong> expression initializes the loop and is only executed once when the loop starts. That is where you must declare and initialize a variable, usually of type int, to hold an initial number that will be used to loop until it reaches a specific value. That can be thought of as the start of the range to iterate over. In our case, we started at 0.</p><p>The <strong>For Loop</strong> will continue looping until the <strong>termination</strong> expression evaluates to <strong>false</strong>. The <strong>termination</strong> expression is evaluated before each iteration of the loop, and it must return a <strong>boolean</strong> to decide whether or not to continue looping. If the <strong>boolean</strong> returned is equal to <strong>true</strong>, we will run the body of our <strong>For Loop</strong> again. In our case, the loop terminates after it prints 9.</p><p><img loading="lazy" decoding="async" class=" wp-image-10519 alignright" src="https://softuni.org/wp-content/uploads/2022/01/for-loops-300x205.png" alt="for-loops" width="306" height="209" srcset="https://softuni.org/wp-content/uploads/2022/01/for-loops-300x205.png 300w, https://softuni.org/wp-content/uploads/2022/01/for-loops.png 460w" sizes="(max-width: 306px) 100vw, 306px" />The increment expression is executed after each iteration of the loop. To increment the variable, we initialize it by using the<strong> ++</strong> operator. That allows the <strong>termination</strong> expression to know how many times the loop loops. The <strong>initialization</strong> variable count, in our example, starts at 0, and it’s printed out. Then the <strong>incrementer</strong> increments it, and the next iteration of the loop runs to print the new value and continues that way until it prints 9.</p><p>In conclusion, you should use a <strong>For Loop</strong> when you know how many times the loop should run. There are other more<strong> advanced iteration structures</strong> that we will look at in the next article.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-88292b4 elementor-widget elementor-widget-video" data-id="88292b4" data-element_type="widget" data-settings="{&quot;youtube_url&quot;:&quot;https:\/\/youtu.be\/VyoaWLnbDi0&quot;,&quot;video_type&quot;:&quot;youtube&quot;,&quot;controls&quot;:&quot;yes&quot;}" data-widget_type="video.default">
				<div class="elementor-widget-container">
							<div class="elementor-wrapper elementor-open-inline">
			<div class="elementor-video"></div>		</div>
						</div>
				</div>
				<div class="elementor-element elementor-element-f6c0ddd elementor-widget elementor-widget-text-editor" data-id="f6c0ddd" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2>Lesson Topics</h2><div><div>In this video we review the following topics:</div><ul><li><b>Increment adn Decrement</b><b></b></li><li><b>For Loops</b></li><li><b>Loops with a Step</b></li><li><b>Iterating over Characters</b></li><li><b>Infinite Loops</b></li></ul></div>								</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				<section class="elementor-section elementor-top-section elementor-element elementor-element-81569e6 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="81569e6" data-element_type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b5437bf" data-id="b5437bf" data-element_type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
							</div>
		</div>
					</div>
		</section>
				<section class="elementor-section elementor-top-section elementor-element elementor-element-a0aff0b elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="a0aff0b" data-element_type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-48c6c18" data-id="48c6c18" data-element_type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-801102c elementor-widget elementor-widget-template" data-id="801102c" data-element_type="widget" data-widget_type="template.default">
				<div class="elementor-widget-container">
							<div class="elementor-template">
					<div data-elementor-type="section" data-elementor-id="20669" class="elementor elementor-20669" data-elementor-post-type="elementor_library">
					<section class="elementor-section elementor-top-section elementor-element elementor-element-2753e750 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="2753e750" data-element_type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b04b054" data-id="b04b054" data-element_type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-50498bde elementor-widget elementor-widget-heading" data-id="50498bde" data-element_type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
					<h2 class="elementor-heading-title elementor-size-default">Practical Exercises</h2>				</div>
				</div>
				<div class="elementor-element elementor-element-6264b7a9 elementor-widget elementor-widget-text-editor" data-id="6264b7a9" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p><strong><span style="font-size: 16px; font-style: normal;">W</span></strong><span style="font-size: 16px; font-style: normal; font-weight: 700 !important;">atch the video</span><span style="font-size: 16px; font-style: normal; font-weight: 400;"> and </span><span style="font-size: 16px; font-style: normal; font-weight: 700 !important;">solve the problems</span><span style="font-size: 16px; font-style: normal; font-weight: 400;">. </span>To better understand the material, do the<strong> coding exercises</strong> and implement the knowledge you acquired. Writing code is the only way to master the <b>skill of code</b>.</p><p>Submit your code in the <b>SoftUni Judge System</b>:</p>								</div>
				</div>
				<div class="elementor-element elementor-element-5a06f887 elementor-cta--layout-image-right elementor-cta--mobile-layout-image-above elementor-cta--skin-classic elementor-animated-content elementor-bg-transform elementor-bg-transform-zoom-in elementor-widget elementor-widget-call-to-action" data-id="5a06f887" data-element_type="widget" data-widget_type="call-to-action.default">
				<div class="elementor-widget-container">
							<a class="elementor-cta" href="https://judge.softuni.org/Contests/3294/Full-Java-Foundations-Course" target="_blank">
					<div class="elementor-cta__bg-wrapper">
				<div class="elementor-cta__bg elementor-bg" style="background-image: url(https://softuni.org/wp-content/uploads/2021/10/softuni-judge-system.png);" role="img" aria-label="softuni-judge-system"></div>
				<div class="elementor-cta__bg-overlay"></div>
			</div>
							<div class="elementor-cta__content">
				
									<h3 class="elementor-cta__title elementor-cta__content-item elementor-content-item">
						Hands-on Exercises in the SoftUni Judge					</h3>
				
									<div class="elementor-cta__description elementor-cta__content-item elementor-content-item">
						Submit your exercise code and check its correctness in the SoftUni Judge.					</div>
				
									<div class="elementor-cta__button-wrapper elementor-cta__content-item elementor-content-item ">
					<span class="elementor-cta__button elementor-button elementor-size-md">
						Go To Judge					</span>
					</div>
							</div>
							<div class="elementor-ribbon elementor-ribbon-left">
				<div class="elementor-ribbon-inner">
					free				</div>
			</div>
				</a>
						</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
				</div>
						</div>
				</div>
				<div class="elementor-element elementor-element-f972417 elementor-widget elementor-widget-heading" data-id="f972417" data-element_type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
					<h2 class="elementor-heading-title elementor-size-default">Exercises: Problem Descriptions</h2>				</div>
				</div>
				<div class="elementor-element elementor-element-3d2f046 elementor-widget elementor-widget-pdfjs_viewer" data-id="3d2f046" data-element_type="widget" data-widget_type="pdfjs_viewer.default">
				<div class="elementor-widget-container">
					<iframe src="https://softuni.org/wp-content/plugins/pdf-viewer-for-elementor/assets/pdfjs/web/viewer.html?file=https://softuni.org/wp-content/uploads/2021/10/Java-Basics-Tutorial-Part-7-For-Loops-Exercises.pdf&amp;embedded=true" style="display: block; margin-left: auto; margin-right: auto; width: 100%; height: 1020px;" frameborder="1" marginheight="0px" marginwidth="0px" allowfullscreen></iframe>				</div>
				</div>
				<div class="elementor-element elementor-element-a49cfaa elementor-widget elementor-widget-heading" data-id="a49cfaa" data-element_type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
					<h2 class="elementor-heading-title elementor-size-default">Lesson Slides</h2>				</div>
				</div>
				<div class="elementor-element elementor-element-37e6760 elementor-widget elementor-widget-pdfjs_viewer" data-id="37e6760" data-element_type="widget" data-widget_type="pdfjs_viewer.default">
				<div class="elementor-widget-container">
					<iframe src="https://softuni.org/wp-content/plugins/pdf-viewer-for-elementor/assets/pdfjs/web/viewer.html?file=https://softuni.org/wp-content/uploads/2021/10/Java-Basics-Tutorial-Part-7-For-Loops.pdf&amp;embedded=true" style="display: block; margin-left: auto; margin-right: auto; width: 100%; height: 1020px;" frameborder="1" marginheight="0px" marginwidth="0px" allowfullscreen></iframe>				</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		<p>The post <a href="https://softuni.org/code-lessons/java-basics-tutorial-part-7-for-loops/">Java Basics Tutorial &#8211; Part 7 &#8211; For Loops</a> appeared first on <a href="https://softuni.org">SoftUni Global</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://softuni.org/code-lessons/java-basics-tutorial-part-7-for-loops/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)

Served from: softuni.org @ 2026-07-16 02:22:08 by W3 Total Cache
-->