Basic Java Language: Difference between revisions
wikademia>Historybuff |
|||
| Line 25: | Line 25: | ||
=Protection= | =Protection= | ||
{{Template:confusing|December 2006}} | {{Template:confusing|December 2006}} | ||
Java allows you to | Java allows you to abstract the internal data of a class from other code that uses that class. The idea here is to create a "black box" effect, where classes that use your class have no knowledge of the internal workings of the class. This simplifies changing the class if done consistently, as other classes don't depend on anything within the class. | ||
There are three '''access modifiers''' and four '''access levels''' (one level is the default, used when no modifier appears). If your class attempts to access another class, it will only be able to if it is allowed access. If you don't have access to the code you're trying to access, the compiler will notice and you'll get a compile-time error. The four levels and three modifiers are as follows: | |||
<center> | <center> | ||