Java Keywords
Some Java keywords for visibility:
- public
- class - Class with main must be public and there can be only one public class per file.
- method - Whether the method can be called from the world.
- field - Is the field available from outside the package
- private
- class - only accessible from within the package
- method - only accessible from within the class
- field - only accessible from within the class
- protected
- class - ?
- method - visible to package and all subclasses
- field - visible to package and all subclasses
- default
- all - visible to the package
Some other Java keywords:
- static
- method - Whether you need an instance to call it (e.g. Math.pow())
- field - see method.
- final
- class - cannot be extended
- method - cannot be overriden
- field - value can be changed once (at construction), after that it cannot be changed. Beware of value vs reference issue!
- abstract
- class - cannot be instantiated. Only useful for inheritance or variable types. Note: Not all methods are abstract.
- method - method is not implemented, but must be implemented in children classes.
- transient - means not serializable, used with fields
There are no comments on this page. [Add comment]