- Introduction to JVM Languages
- Vincent van der Leun
- 81字
- 2021-07-02 21:46:34
Adding class members - variables and methods
Without variables and methods, classes would be boring and rather pointless. Variables hold data that methods usually act upon. Like classes, the visibility of both variables and methods can be changed by prefixing them with access modifiers, but both support additional modifiers. We'll describe the syntax to define variables and methods first, then continue with modifiers. This leads us to the following topics:
- Instance variables
- Instance methods
- Access modifiers
- Static modifier
- Final modifier
- Method overloading