Java® classes can contain member variables called fields which might have public or private access . To access public data fields, which your code can read or modify directly, use the syntax: object.field. To read from and, where allowed, to modify private data fields, use the accessor methods defined by the Java class.