Skip to Content
Learning Java by Building Android Games - Third Edition
book

Learning Java by Building Android Games - Third Edition

by John Horton
March 2021
Beginner to intermediate
686 pages
13h 6m
English
Packt Publishing
Content preview from Learning Java by Building Android Games - Third Edition

Chapter 6: Repeating Blocks of Code with Loops

In this brief chapter, we will learn about Java loops and how they enable us to repeat sections of our code in a controlled manner. Loops in Java take a few different forms and we will learn how to use them all. Throughout the rest of this book, we will put each of them to good use.

In this chapter, we will cover the following topics:

  • Making decisions with Java
  • Some more Java operators
  • While loops
  • Do while loops
  • For loops
  • How to draw the grid lines of the Sub' Hunter game (using loops)

This is the second to last chapter before we complete the first game and move on to a more advanced project.

Making decisions with Java

Our Java code will constantly be making decisions. For example, we might

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Java by Building Android Games - Second Edition

Learning Java by Building Android Games - Second Edition

John Horton
Programming Android with Kotlin

Programming Android with Kotlin

Pierre-Olivier Laurence, Amanda Hinchman-Dominguez, Mike Dunn, G. Blake Meike

Publisher Resources

ISBN: 9781800565869Supplemental Content