O'Reilly logo

Android Programming for Beginners by John Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The basic classes mini app

The generals who will be using our app will need more than one Soldier object. In our app that we are about to build, we will instantiate and use multiple objects. We will also demonstrate using the dot operator on variables and methods to show that different objects have their very own instance variables.

You can get the completed code for this example in the code download. It is in the chapter 9/Basic Classes folder. Alternatively, read on to create your own working example.

Create a project with a blank activity. Call the application BasicClasses. Now, we create a new class called Soldier:

  1. Right-click the com.gamecodeschool.basicclasses (or whatever your package name is) folder in the project explorer window.
  2. Select ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required