Hi everyone, I'm having trouble understanding something, and I think an assumption is being made that I'm not aware of. In Kathy and Bert's SCJP2 cert book on page 73 there is a class called Toon which invokes the doRooThings method on a Cloo instance. However, should i assume that the Toon class is in the same package as Cloo? The text doesn't specify a package name for the Toon class. Here is the code:
I thought that since the Roo class is not marked public that only classes in the same package can access members of this class. There isn't a package declaration for class Toon. Is it in the same package as Cloo? I know it looks like it is here in this example, but the book is unclear whether it is or isn't. Also, since class Toon doesn't extend Cloo, then I'm invoking the method doRooThings in class Toon from the Cloo class, right? [ May 21, 2003: Message edited by: leo donahue ]
Cowgirl and Author
Joined: Oct 10, 2002
Howdy -- you are absolutely right -- in order for this code to work, class Toon must have been declared in the same package as Cloo, since Cloo is not public. We didn't specify it either way because, well, because I have no idea why. We should have made it explicit! But you figured out what must be true in order for that to work. We were concentrating on the actual doRooThings() method rather than the class itself. Sorry, and thanks for the catch cheers, Kathy
Joined: Apr 17, 2003
Kathy, Thanks for your response. Nothing to be sorry about. I just wanted to be sure I was following your example correctly.