Language syntax

Java Instance field

Stores per-object state and receives a default before explicit initialization.

Formal Syntax & Structure

java syntaxjava
Type fieldName;

Working Example

Example Snippetjava
class Label {    int number;    boolean printed;    String text;}public class Main {    public static void main(String[] args) {        Label label = new Label();        System.out.println(label.number);        System.out.println(label.printed);        System.out.println(label.text);    }}
Java Reference