Chapter 4: Object-Oriented Programming in Java
In This Chapter
Using classes with finesse
Working with Java’s classes and interfaces
Being part of Java’s inner circle
If you remember nothing else about Java, remember these ideas from Chapter 2 of this minibook:
Java is an object-oriented programming language. So, as a developer, your primary goal is to describe objects. Your closely related goal is to describe objects’ close cousins —; namely, classes. A class is the idea behind a certain kind of thing. An object is a concrete instance of a class.
And if you remember nothing else about those ideas, remember the following two-word summary:
Classes; objects.
Chapter 2 in this minibook covers the highlights of object-oriented programming in Java. This chapter covers some of object-oriented programming’s finer points.
Static Fields and Methods
In Listing 4-1, I reproduce a small portion of the source code of Android’s Toast
class.
Listing 4-1: An Unrepresentative Sample of Android’s Toast Class Code
public class Toast {
public
static
final int LENGTH_LONG = 1;
public
static
Toast makeText(Context context,
CharSequence text,
int ...