ASA Programming Guide
Introduction to Java in the Database
A Java seminar
There are two categories of Java fields:
Instance fields Each object has its own set of instance fields, created when the object was created. They hold information specific to that instance. For example, a lineItem1Description field in the Invoice class holds the description for a line item on a particular invoice. You can access instance fields only through an object reference.
Class fields A class field holds information that is independent of any particular instance. A class field is created when the class is first loaded, and no further instances are created no matter how many objects are created. Class fields can be accessed either through the class name or the object reference.
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.
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; }