Introduction to Interactive Programming
by Lynn Andrea Stein
A Rethinking CS101 Project

Java Charts

Field Declaration4

public
protected
private
Optional: 0 or 1.

If public, the field is visible and settable everywhere, and inherited by all subclasses.
If protected, it is visible and settable within the package but inherited everywhere.
If private, it is visble nowhere, nor is it inherited.

Otherwise, it is visible, settable, and inheritable only within the package.

static Optional: 0 or 1.

If static, the field belongs to the class (factory, recipe) and not to its instances. In this case, it is referenced as ClassName.fieldName rather than through its instances.

final Optional: 0 or 1.

If final, the field must be initialized at its creation time, and its value cannot later be changed.

TypeName Exactly 1.

May be a class or interface name, one of the eight Java primitive types, or an array type.

fieldName Exactly 1.
= value Optional: 0 or 1.

If present, value be an expression assignable to type TypeName. This is an initialization expression, and it makes this declaration into a definition.

; Exactly 1.


This course is a part of Lynn Andrea Stein's Rethinking CS101 project at the MIT AI Lab and the Department of Electrical Engineering and Computer Science at the Massachusetts Institute of Technology.