Here is a class declaration for a class called Person. It is rather basic as it can be used to store only a name, a date of birth and a height:
0511: import java.util.StringTokenizer; // Person.java 0512: public class Person { 0513: public Person() { this("", 0.0F, new Date()); } 0514: public Person(String pString) { 0515: StringTokenizer tTokens = new StringTokenizer(pString, "%"); 0516: oName = tTokens.nextToken(); 0517: iHeight = Float.valueOf(tTokens.nextToken()).floatValue(); 0518: oDateOfBirth = new Date(tTokens.nextToken()); 0519: } 0520: public Person(String pName, float pHeight, Date pDate) { 0521: oName = pName; iHeight = pHeight; oDateOfBirth = pDate; 0522: } 0523: public String getName() { return oName; } 0524: public boolean equals(Object pObject) { 0525: return oName.equals(((Person) pObject).oName); 0526: } 0527: public String toString() { 0528: return oName + "%" + iHeight + "%" + oDateOfBirth; 0529: } 0530: protected String oName; 0531: private float iHeight; 0532: protected Date oDateOfBirth; 0533: }Although this class declaration has protected fields, for the time being treat the protected fields as if they were private fields. The distinction between the two will be discussed later.