Contents Index Class constructors Understanding methods

ASA Programming Guide
  Introduction to Java in the Database
    A Java seminar

Understanding fields


There are two categories of Java fields:

To declare a field in a class, state its type, then its name, followed by a semicolon. To declare a class field, use the static Java keyword in the declaration. You declare fields in the body of the class and not within a method; declaring a variable within a method makes it a part of the method, not of the class.

Examples 

The following declaration of the class Invoice has four fields, corresponding to information that might be contained on two line items on an invoice.

public class Invoice {

    // Fields of an invoice contain the invoice data
    public String lineItem1Description;
    public int lineItem1Cost;

    public String lineItem2Description;
    public int lineItem2Cost;

}

Contents Index Class constructors Understanding methods