Starting on page 143, the book as some advice on getting assistance from Android Studio on creating override methods.
The book will show something like:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
while Android Studio actually produces the following with the @Nullable annotation:
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
I understand that the @Nullable annotation is to make it clear that null is an acceptable value for that parameter, but why is does the book not show that? Is it just to keep the code listings as clean as possible?
Yes. We’re trying to simplify things so that the reader isn’t overwhelmed.
If we include the @Nullable annotation, we’d also need to explain it. In this case, I personally don’t feel like it adds a lot of value so we don’t use it in the book.
@cstewart – makes complete sense. One thing that might be useful though is a footnote to tell the reader they can safely ignore (and even remove) the @Nullable annotation that Android Studio will generate.
That would be nice addition to your list. I’ve seen onCreate() function in different books without the @nullable so I’ve never been bothered by it because I know it works with or without it. Nice point @Kim