This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Marianne Rivera wrote:I thought setting a private access modifier will prevent my instance variable from being set incorrectly.
But when I compile this class using javac, I encounter no error.
That's allowed only within the same class as the private variable. No one can access it directly outside the class.
I thought there will be an error in the head first java book.
I am having a hard time figuring how to learn java..
You are with the right material. Just work out the things in the book.
So thats the reason. Now I understand why the book is always talking about the TestDrive Class though I am not yet sure about the keyword static upto now. Maybe later the book will explain it to me.. hopefully..