Using Java packages

Packages are grouped collections of classes. If you look at the top of the code that we have written so far, you will see these lines of code.

import android.app.Activity;
import android.os.Bundle;

These lines of code make available the Activity and Bundle classes as well as their methods. Comment out the above two lines like this:

// import android.app.Activity;
// import android.os.Bundle;

Now look at your code and you will see errors in at least three places. The word Activity has an error because Activity is a class which Android Studio no longer is aware of in the following line:

public class SubHunter extends Activity {

The word onCreate also has an error because it is a method from the Activity class and the word Bundle ...

Get Learning Java by Building Android Games - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.