Java for Humans {Encapsulation & Access Modifiers}

Lincoln W Daniel
ModernNerd Code
Published in
6 min readJan 8, 2016

--

View Table of Contents | Download Supporting Code | Subscribe to ModernNerd Youtube Channel for Coding Videos | By Lincoln W Daniel

As humans, we make use of the tools provided to us by companies, our parents, teachers, friends, and government. Most times, we don’t care about how the tools work behind the scenes; all we care about is that they work and get the job done when we call on them.

When you go to a vending machine and pay for cookies with a dollar bill, you don’t necessarily care how the machine knows you gave it a valid dollar instead of a piece of printer paper, but you do expect it to accept your dollar as a form of payment and for it to dispense your cookie. If the cookie only cost $0.75, you expect the machine to also give you a quarter back and you don’t care how it manages to do that. You are unaware of the amount of money the machine has in it and how it does the math to decide how much money to give back to you. With that, we can say that all of its functions are encapsulated.

The English dictionary defines “encapsulate” as so:

to enclose (something) in or as if in a capsule.

In computer science, we define encapsulation as such:

to provide an interface for (a piece of software or hardware) to allow or simplify access for the user.

--

--

Lincoln W Daniel
ModernNerd Code

Chief Bull @ BullAcademy.org ® Elevating writers @ ManyStories.com. Author @JavaForHumans Ex: Editor in Chief MarkGrowth (acq.), Engineer @Medium @GoPuff