Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Java Programming for Beginners

You're reading from   Java Programming for Beginners Learn the fundamentals of programming with Java

Arrow left icon
Product type Paperback
Published in Oct 2017
Publisher Packt
ISBN-13 9781788296298
Length 318 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
SkillSprints Inc., Mark Lassoff SkillSprints Inc., Mark Lassoff
Author Profile Icon SkillSprints Inc., Mark Lassoff
SkillSprints Inc., Mark Lassoff
Arrow right icon
View More author details
Toc

While and do...while loops

Welcome to the introductory lesson on loops. At the end of this section, we'll have command over Java's while and do...while loops. I'm pretty excited about this because loops allow us to execute a block of Java code over and over again as many times as we see fit. This is a pretty cool step in our learning process because the ability to perform small tasks many times in rapid succession is one of the things that makes computers better at certain tasks than humans are:

  1. To begin this topic, let's create a new NetBeans project, enter the main method, and simply declare an integer and give it a value. We can choose any positive value. We're going to ask our program to print out the phrase Hello World a number of times equal to the value of our integer.
  1. To do this, we'll employ a while loop. The while loop syntax looks a...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime