The structure of Java code – revisited

We have already seen that each time we create a new Android project, we also create a new Java package as a kind of container for the code we write.

We have also learned about and played around with classes. We have imported and taken direct advantage of classes from the Android API, such as Log and Toast. We have also used the AppCompatActivity class, but in a different manner to that of Log and Toast. You might recall that the first line of code in all our projects so far, after the import statements, used the extends keyword:

public class MainActivity extends AppCompatActivity {

When we extend a class, as opposed to just importing it, we are making it our own. In fact, if you take another look at the line ...

Get Android Programming for Beginners - 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.