Book Image

Learning Java by Building Android Games - Third Edition

By : John Horton
5 (1)
Book Image

Learning Java by Building Android Games - Third Edition

5 (1)
By: John Horton

Overview of this book

Android is one of the most popular mobile operating systems today. It uses the most popular programming language, Java, as one of the primary languages for building apps of all types. Unlike most other Android books, this book doesn’t assume that you have any prior knowledge of Java programming, instead helps you get started with building Android games as a beginner. This new, improved, and updated third edition of Learning Java by Building Android Games helps you to build Android games from scratch. Once you've got to grips with the fundamentals, the difficulty level increases steadily as you explore key Java topics, such as variables, loops, methods, object-oriented programming (OOP), and design patterns while working with up-to-date code and supporting examples. At each stage, you'll be able to test your understanding by implementing the concepts that you’ve learned to develop a game. Toward the end, you’ll build games such as Sub Hunter, Retro Pong, Bullet Hell, Classic Snake, and Scrolling Shooter. By the end of this Java book, you'll not only have a solid understanding of Java and Android basics but will also have developed five cool games for the Android platform.
Table of Contents (24 chapters)

How Java and Android work together

Before we start our Android quest, we need to understand how Android and Java work together.

Android is a complex system, but you do not need to understand it in depth in order to make amazing apps.

After we write a program, in Java, for Android, we click on a button, and our code is transformed into another form – the form that is understood by Android. This other form is called bytecode, and the transformation process is called compiling. The reason you can use the Kotlin programming language to write Android apps is that it directly compiles to the same bytecode as Java. In fact, Java can be translated to Kotlin with the click of a button.

Then, when the user installs our application, the bytecode is translated by another process, known as the Android Runtime (ART), into machine code. This is the fastest possible execution format. So, if you have ever heard people saying that you shouldn't use Java because it is slow, then...