Chapter 14
Sharing Names among the Parts of a Java Program
IN THIS CHAPTER
Hiding names from other classes
Exposing names to other classes
Tweaking your code to find the right middle ground
Speaking of private fields and methods (and I do speak about these things in this chapter) …
I’m eating lunch with some friends at work. “They can read your email,” says one fellow. Another chimes in, “They know every single website that you visit. They know what products you buy, what you eat for dinner, what you wear, what you think. They even know your deepest, darkest secrets. Why, I wouldn’t be surprised if they know when you’re going to die.”
A third voice enters the fray. “It’s getting to the point where you can’t blow your nose without someone taking a record of it. I visited a website a few weeks ago, and the page wished me Happy Birthday. How did they know it was me, and how did they remember that it was my birthday?”
“Yeah,” says the first guy. “I have a tag on my car that lets me sail through toll booths. It senses that I’m going through and puts the charge on my credit card automatically. Every month, I get a list from the company showing where I’ve been and when I was there. I’m ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access