Listing 9.1 in page 169


#1

public class [color=#0000FF]CrimeLab[/color] {
private static [color=#0000FF]CrimeLab[/color] sCrimeLab;

I’m sorry I’m not a Java expert, is it possible a class declares it’s own class object variable?
If so, could you please point out any book or web site explains it?

Thanks,
doomoo


#2

Yes, it is possible and that is part of the singleton design pattern and other design patterns. The book “Head First Design Patterns” has an easy to understand explanation of singletons and all the examples are in Java. For learning the basics of Java I used “Java, A Beginner’s Guide, 5th Edition” by Schildt. It’s a very gentle introduction while at the same time covering everything you need to understand the Big Nerd Ranch Java. Actually, maybe not everything but 99%. For the rest there is stackoverflow.


#3

Thank you so much.
I just checked “Head First Design Patterns” has an explanation on singleton and my question.

doomoo