Java Reference
In-Depth Information
Finally, data members can also be assigned the static access control. This con-
trol specifies that only one instance of the data member exists, and it is available to
all instances of this class in the current run unit. In Java, you call this type of vari-
able a class variable. In this sense, these types of data items are like data items in a
COBOL subroutine's WORKING-STORAGE. That is, only one instance of this
variable exists, and every class of this type can access it.
Static class members can be either public, private, or protected. If a static data
item is private, then only classes of this type can access it (like WORKING-STOR-
AGE items in COBOL). If a static data item is public, then every other class can ac-
cess it as well (like the EXTERNAL access control in COBOL).
Just like data members, Java methods can also be declared as public, private,
package, or static. For example, these statements
public void setErrorMsg (String inputMsg) () {
private void countErrorMsg () {
void checkErrorMsg (String inputMsg) {
public static void SETLANGUAGE (char languageFlag) {
define four methods: one public , one private , one package method, and one that is
a static method. The default access control is package , which is why checkErrorMsg
does not have a qualifier.
 
Search WWH ::




Custom Search