Fields in java class

This page discusses - Fields in java class

Fields in java class


In this section, we will explore the concept of the fields in the reference of object oriented programming techniques.

There are two part of the field first is type of field and other one is the name part. We can also define the visibility of that field. There are four type of visibility of that:

Public: The field can be access in the entire class.

Protected: The field define in this section will access by the class, subclass or classes in the same package.

Private: This type of field can be access by the same elements of the class.

Package: The field can be access by any class objects from classes inside the same package in which the field is defined.

We can also define the modification style of the field. There are also four type of modification style.

Static: This type of modifiers are define to the class not to the object.

Transient: This type of field is use to store for the constant value.

Final: The field can not be changed from its assigned value.

Volatile: This type of field can be customized as you might expect at the same time of running threads.