Site updates
Testing New System now...

Public, Private and Protected

A method or variable should be declared private when other classes shouldn't be able to operate on them directly. For example, the balance of a bank account class should be private, and accessed by methods.

It may seem stupid in some instances, but consider what would happen if the process suddenly changed and, for example, a log of all transactions was required. If the program had been written in such a way that direct manipulation from other classes was used, then all of these instances of code would have to be found and changed. If the variable had been manipulated by a method, then one update would be all that was needed.

A protected method can only be altered by it's subclasses

Methods and variables should only be declared public if they are needed, such as constants or part of the object's interface. If they shouldn't be tampered with, then they definitely should be private.

NOTE: The Java section is mostly in maintenence mode. I don't have time to work on it right now. Errors will be corrected if pointed out, but they are not actively being searched for. Newer site features, like alternate stylesheets, may cause problems with these pages.